ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  PHP Form Handling
Subject:   A name thats end with [] doesn't work well with JavaScript
Date:   2007-08-16 08:43:43
From:   Marion_Amsterdam
"2. Put [] at the end of the name of a multivalued form parameter."


When using AJAX / JavaScript in your form, you'd better not use names/id's with [] at the end. It will make the form element inaccesibile for the JavaScript function document.getElementById() and you won't be able to address the element with document.mywebform.name[]. Solution: save the selected options as a string in a comma seperated list, and make this string the value of a hidden input element. In your php script, explode() this string