selectbox

R

Richard

Hello,

When I have the next example, it shows me if item 2 is selected YES or NO

<html>
<script language="javascript">
function doit()
{
alert(document.forms["tst_frm"].elements["listbox"].options[2].selected)
}
</script>

<body>
<FORM id=tst_frm name=tst_frm action=javascript:doit() method=post>
<SELECT multiple size=5 name=listbox>
<OPTION value=1>1</OPTION>
<OPTION value=2>2</OPTION>2
<oPTION value=3>3</OPTION>
<OPTION value=4>4</OPTION>
<OPTION value=5>5</OPTION>
</SELECT>

<INPUT type=submit value="DOit" name=submit>

</FORM>
</body>
</html>

When I change then name field to a name with brackets (array)

<SELECT multiple size=5 name=listbox[]> It won't work. How can the
javascript work with the brackets in the name fields

Many thanks in advance

Richard
 
R

richard

Wat is I want to do is create an listbox where you can select multiple
items. The selection must be handedover to PHP as an array. The PHP code is
running fine.
Before the form is submitted, I have to check releatiosn to other field in
the form. To simplify it, I made small example which has the same behaviour.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top