PDA

View Full Version : why wont this work?


bioTINMAN
01-25-2008, 08:33 AM
why wont this work?



<head>
<script type="text/javascript">
function add(vak)
{
alert(document.win.getElementByName('yoohoo'+vak).value);

}
</script>

</head>

<body>

<form name="win">
<input type="text" name=yoohoo1 value="3" onChange="add(1);">
</form>
</body>

shyam
01-25-2008, 08:53 AM
why wont this work?



<head>
<script type="text/javascript">
function add(vak)
{
alert(document.win.getElementByName('yoohoo'+vak).value);

}
</script>

</head>

<body>

<form name="win">
<input type="text" name=yoohoo1 value="3" onChange="add(1);">
</form>
</body>


getElementsByName is defined on the document object.... there are other ways to acesss the textfield

* add an id and use document.getElementById
* document.win['yoohoo' + vak].value
* document.forms['win']['yoohoo' + vak].value