RSS

Form's array element in javascript

11 Jul

How to access form’s array element in javascript?

Web Post
Mobile Post
Application Post
Open Source Post

Solution:

<form action=”<?=$_SERVER[‘PHP_SELF’]?>” method=”post”>

<input name=”post[]” type=”checkbox” value=”web” /> Web Post
<input name=”post[]” type=”checkbox” value=”mobile” /> Mobile Post
<input name=”post[]” type=”checkbox” value=”application” />Application Post
<input name=”post[]” type=”checkbox” value=”open” /> Open Source Post

</form>

<script type=”text/javascript”>
for(i=0;i
{

if(document.sv.elements[i].type==”checkbox” && document.sv.elements[i].name==”post[]”)
{

if(document.sv.elements[i].checked==true)
alert(document.sv.elements[i].value);

}

}
</script>

Advertisements
 
Leave a comment

Posted by on July 11, 2009 in javascript, Tips, Tricks

 

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: