Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forcing a Selection in a <Select Multiple> list 1

Status
Not open for further replies.

ducky62

Programmer
Jul 10, 2001
24
CA
I have

Set objRst = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblTimeMatrix ORDER BY fldTechnology, fldTechID"
objRst.Open strSQL, objConnection
%>
<select name=&quot;listTech&quot; size=&quot;10&quot; multiple>
<%
Do While Not objRst.EOF
%>
<option <%=objRst(&quot;fldTechID&quot;)%>><%=objRst(&quot;fldTechID&quot;)%> # <%=objRst(&quot;fldTechnology&quot;)%> # <%=objRst(&quot;fldEquipment&quot;)%> # <%=objRst(&quot;fldTechDesc&quot;)%> # <%=objRst(&quot;fldHours&quot;)%> Hours <%
objRst.MoveNext
Loop

objRst.Close
Set objRst = Nothing
objConnection.close
Set objConnection = Nothing

%>
</select>

and I want the user to be forced to select at least one of these before they submit

any ideas?
 
You could try changing your submit button to just a normal button, then add code to it to check that a selection has been made, if it has submit your form.

like this

<script language=&quot;vbscript&quot;>
sub button_Onclick()
set x = document.all(&quot;list1&quot;)
if x.selectedindex > -1 then
form1.submit
else
msgbox &quot;You need to select from the list!&quot;
end if

hope this helps!

Mat
end sub
</script>
 
sorry, my end sub is in the wrong place!

just thought, make sure this is client side script!

Mat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top