get html array filed in javascript

Hewlett-packard Mini 210-1010nr netbook
April 24, 2011 at 08:51:50
Specs: Windows XP, 1
Bellow is my code, i am trying to get out of my html form the value of submit[] and pass it to javascript.
i have a number of submit[] and i want to know how to call each and one of them.
but not through element because then i will have to call them by there name, which i dont want.
i have tried submit[0] but it doesnt work either.
unfortunatly all i get is undefined.

<html>
<head>

<script type="text/javascript">
function validateForm()
{
x = document.forms["myForm"]["submit[]"].value;
alert(x);
}
</script>

</head>

<body>
<form name="myForm" onsubmit="return validateForm()">

Server: <input type="text" name="server" value="server" /><br />
<input type="submit" value="Show Databases" " name="submit[]"/>

Server2: <input type="text" name="server" value="server" /><br />
<input type="submit" value="Show walla" name="submit[]"/>

</form>
</body>

</html>

thanks in advance


See More: get html array filed in javascript

Report •


#1
April 25, 2011 at 01:28:12
Im not sure what your trying to do, but if you dont want to get the elements by name, you can use childnodes

http://www.howtocreate.co.uk/tutori...


Report •

#2
April 26, 2011 at 10:14:41
It sounds like you're trying to display the value of an item in an array, but you haven't actually created the array.
http://w3schools.com/js/js_obj_arra...

Apologies if I don't respond to your reply immediately. I don't check this site daily, but you're welcome to PM me as a reminder.


Report •

#3
June 2, 2011 at 02:50:43
Hi guys
thanks for your response i have manage to use the 'document.pressed' to identify which submit[] was pressed and get the value="Show Databases" out of it.
thanks in advanced

Report •
Related Solutions


Ask Question