zimminy Posted June 30, 2012 Share Posted June 30, 2012 Why does this not work? it returns "undefined" for the Strings - I want to use an image, not a button, and yet I can make it work with a button but not an image. I've been reading through newbie tutorials all evening and have tried every twist I could find. W3schools says an onClick event can be used on an image, but somehow it's wrong. Thanks for the help! <html> <head> <script type="text/javascript"> <!-- function votYes(vnum,fnum){ var myString=vnum.value; var myString2=fnum.value; var myNewString = "you voted a number " + myString + " for food item number " + myString2; var box = document.getElementById('box');box.innerHTML = myNewString; } // --> </script> </head> <body> Food Item 1 <div name="box" id="box"><img src="one.gif" onclick="votYes(1,33);" border="0" /></div><br><br> </body> </html> You can see my train wreck here: http://mommatown.net/practice_js3.php Quote Link to comment https://forums.phpfreaks.com/topic/265024-help-the-noob-incorrectly-passing-arguments-to-my-formula/ Share on other sites More sharing options...
requinix Posted June 30, 2012 Share Posted June 30, 2012 Your onclick passes numbers to votYes() but the function itself is expecting some kind of objects (presumably textboxes). Quote Link to comment https://forums.phpfreaks.com/topic/265024-help-the-noob-incorrectly-passing-arguments-to-my-formula/#findComment-1358097 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.