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

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.