cesarcesar Posted June 5, 2007 Share Posted June 5, 2007 Why wont this work? checkFields() iF statment is failing. The select must be set to multiple. Thanks. <form method="POST" action="" name="this_form"> <select name="this_select" multiple> <option value="ts1">ts1</option> <option value="ts2">ts2</option> <option value="ts3">ts3</option> <option value="ts4">ts4</option> </select> </form> <script language="Javascript"> <!-- function checkFields(){ var errormsg = ""; if (document.this_form.this_select.value == "") { var errormsg = errormsg + "Please Select an Value.\n\r"; } if (errormsg != "") { alert(errormsg); return false; } } //--> </script> Quote Link to comment Share on other sites More sharing options...
cesarcesar Posted June 5, 2007 Author Share Posted June 5, 2007 Forgot submit <form method="POST" action="" name="this_form" onSubmit="return checkFields();"> <select name="this_select" multiple> <option value="ts1">ts1</option> <option value="ts2">ts2</option> <option value="ts3">ts3</option> <option value="ts4">ts4</option> </select> </form> Quote Link to comment Share on other sites More sharing options...
cesarcesar Posted June 5, 2007 Author Share Posted June 5, 2007 Why wont this work? checkFields() iF statment is failing. The select must be set to multiple. Thanks. <form method="POST" action="" name="this_form" onSubmit="return checkFields();"> <select name="this_select[]" multiple> <option value="ts1">ts1</option> <option value="ts2">ts2</option> <option value="ts3">ts3</option> <option value="ts4">ts4</option> </select> </form> <script language="Javascript"> <!-- function checkFields(){ var errormsg = ""; if (document.this_form.this_select.value == "") { var errormsg = errormsg + "Please Select an Value.\n\r"; } if (errormsg != "") { alert(errormsg); return false; } } //--> </script> Quote Link to comment Share on other sites More sharing options...
cesarcesar Posted June 5, 2007 Author Share Posted June 5, 2007 solution: document.this_form.elements['this_select[]'].value Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.