Hello All,
I have a multi-select list box, In this box is a list of names. I want to call a javascript onClick that will keep a running total of how many people were clicked. As soon as a user tries to click the 41st item (only 40 allowed) I want to alert the user, they cannot select more then 40 participants in this box.
Here is what i have so far:
can someone please explain to me where im going wrong and how to get this working. Im not looking to have it done for me without an explanation. I would love to understand this as im sure I will need to write more functions like this in the future.
thanks,
John
I have a multi-select list box, In this box is a list of names. I want to call a javascript onClick that will keep a running total of how many people were clicked. As soon as a user tries to click the 41st item (only 40 allowed) I want to alert the user, they cannot select more then 40 participants in this box.
Here is what i have so far:
Code:
<script>
function KeepTotal(){
var i;
i = i + 1;
if (i > 40)
{
alert('You can only select 40 names');
}
}
</script>
<select name="participants" onClick="javascript:KeepTotal();" multiple>
<option value="1">Name 1</option>
<option value="2">Name 2</option>
... (about 150 names in total populated from a db)
</select>
thanks,
John
Comment