RSS

Tag Archives: document.form.elements[i].checked

Form's array element in javascript

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, LAMP, Tips, Tricks

 

Tags: , ,

Form's array element in javascript

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>

 
Leave a comment

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

 

Tags: , ,