Form's array element in javascript

On July 11, 2009, in Javascript, Tips, Tricks, by admin

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>

3 Responses to Form's array element in javascript

  1. Anonymous says:

    Thanks for sharing superb informations. Your websiteis so cool.I am stunned at the important points that you’ve on this blog. It reveals how nicely you perceive this subject. Bookmarked this web site, will happen backfor extra articles. You, my pal, ROCK! I ran across this is the info I already searched in all places and just couldn?t discover. What a ideal website. I prefer this web web page and your website is without question one of my new favorite ones.I’m keen on this site given possesses given me some form of dedication achievement for a few purpose, so thanks

  2. Anonymous says:

    You completed several good points there. I did so research online for the issue and located virtually all people is going together with using your blog.

  3. Lonitra says:

    You get a lot of respect from me for writing these helfupl articles.

Leave a Reply