Domanda

I got these checkbox:

<form name="achievements_list" id="achievements_list" action="achievements.php" method="POST">

foreach($sample1 as $sample2){
<input type="checkbox" value="'.$sample2.'" name="achievementlist[]"/>
}

and a simple limiter that don't works if the checkbox name is set as an array:

<script type="text/javascript">
//Syntax: checkboxlimit(checkbox_reference, limit)
checkboxlimit(document.forms.achievements_list.achievementlist, 5)
</script>

the limiter is not working because the input checkbox name have brackets [].

How to make it work?

È stato utile?

Soluzione

Accessing the form with the syntax

myForm["myelement"]

has the same result as myForm.myelement, except that it also allows javascript illegal identifiers or grammars constructs that would cause unexpected results (in your case: trying to access an undefined element as an array instead of getting an element by name which is using a PHP-expectable array notation)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top