Jump to content

[SOLVED] Update a text field


papaface

Recommended Posts

Hello,

Could someone tell me how I would go about doing the following:

I would like to be able to click on an image, and have its id inserted into a text field.

Like this:

<img src="smile.gif" id=":)" />

insert the id into:

<input name="text" type="text" size="20"/>

 

Any help would be appreciated. I really need this :)

Link to comment
https://forums.phpfreaks.com/topic/39743-solved-update-a-text-field/
Share on other sites

Hi,

This is the solution:

onclick="document.shoutbox.submit_shout.value=document.shoutbox.submit_shout.value+this.id;"

it translates to:

onclick="document.FORM.TEXBOX.value=document.FORM.TEXTBOX.value+this.id;"

 

I have a problem though on my page can anyone help?

I have this code:

<input name="submit_shout" type="text" class="textboxes"  onClick="MM_setTextOfTextfield('submit_shout','','')" value="Message" size="20"/>

And it is conflicting with this code.

<img src="images/smileys/bad.gif" width="18" height="18" id=":bad:" onclick="document.shoutbox.submit_shout.value=document.shoutbox.submit_shout.value+this.id;" />

When i click on the image it is supposed to add the image ID to the text field.

It does that, however when i click in the text field it clears it.

I still want to have the ability to clear the text field but ONLY if they text fields value is "Message".

How can this be achieved?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.