views:

22

answers:

4

HI All,

I know this is bit strange question, but please suggest.

I want to create a link on website url content in input type"text" field not any other html tag,Is it possible and if yes how.

Regards & Thanks Amit

A: 

You want someone clicking a textbox to actually be treated as a link click?

Sounds malicious to me but you could bind the focus event via javascript to a window.redirect().

Graphain
A: 

I don't know if I get the question right. As I've understood you want to be able to type in a ...-tag into an input-field. No other tags should be allowed. You can achieve this by using PHP for example:

<!-- HTML-Code -->
<input type="text" name="link" />

// PHP-Code
$link = strip_tags($_POST['link'], 'a'); // Remove all other tags than the <a>-Tag...

Is that what you mean?

faileN
Thanks for your reply , i mean to make the entered text a hyperlink inside the input box.Hope i m clear this time :)
Jos
A: 

I don't know whether I understood your question correctly or not. Based on my understanding I gave the answer. Feel free to raise your question. Nothing is impossible.

<a href="http://www.google.com" ><input type='text' style="border:1px solid blue;"></input></a>

It displays a text box. You can enter any data into it. If you press enter key then it forwards the page to Google.com

You can use SPAN instead of INPUT. This also serve the same purpose.

<a href="http://www.google.com" ><span style="border:1px solid blue;" >Link</span></a>
Multiplexer
Thanks for your reply but this will make the complete textbox linkable, which i dont want....any other alternative, to make only content of textbox clickable.
Jos
ok can we add cursor hand over the textbox content.
Jos
Do want the text box readonly ?
Multiplexer
yes the text box is readonly
Jos
Then you can replace the <input> with <span>. That will solve your problem. Check the answer again.
Multiplexer
That i cannot do as i dont want any other tag in place of input, but some how i managed to get some work aroud , now i want to show cursor hand over text box content.Is it possible.And thanks a lot for all replies.. :)
Jos
Hmmm, I can understand. To show cursor hand you may need to say the input text box is disabled. Using onmouseover event you can set the cursor as hand. The code looks like <input type="text" onmouseover="funconmouseover(this)" />. Your javascript code looks like function funconmouseover(obj) { obj.cursor = "hand"; }.. try like this. all the best.
Multiplexer
thanks but that did not helped me...will keep on trying this.in case you find anyhtnig..please do tell me .Thanks a lot
Jos
A: 

Yes, it is possible, but it's not that simple. You need to create div, or other tag you prefer, that will be always floating over your input, using CSS positions, and create anchor inside it.

For example, virtual keyboard img is embedded into input field that way on russian Google page (http://www.google.ru/)

Because of browser-compatibility it's not a simple task.

EDIT: Understood your question a little more. You still need first part of the answer, and you will need to handle keypress event inside your input. When symbol is entered you will need to update your floating div.

So now task is difficult even more. Maybe you should revise your model and not the code.

Chaotic_one