papaface Posted February 23, 2007 Share Posted February 23, 2007 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 Quote Link to comment Share on other sites More sharing options...
papaface Posted February 23, 2007 Author Share Posted February 23, 2007 Solved Quote Link to comment Share on other sites More sharing options...
artacus Posted February 23, 2007 Share Posted February 23, 2007 Glad we could help Post your solution though. Because two years from now some poor sap is going to have the same problem and when he finds your post, it wont do him any good. Quote Link to comment Share on other sites More sharing options...
papaface Posted February 23, 2007 Author Share Posted February 23, 2007 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted February 23, 2007 Share Posted February 23, 2007 Wrap it in an "if( document.shoutbox.submit_shout.value == 'Message') " Quote Link to comment Share on other sites More sharing options...
papaface Posted February 23, 2007 Author Share Posted February 23, 2007 Thanks, works great. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.