Jump to content

help the noob - incorrectly passing arguments to my formula


zimminy

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.