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> Link to comment https://forums.phpfreaks.com/topic/54248-form-arrays-in-javascript/ 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> Link to comment https://forums.phpfreaks.com/topic/54248-form-arrays-in-javascript/#findComment-268224 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> Link to comment https://forums.phpfreaks.com/topic/54248-form-arrays-in-javascript/#findComment-268236 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 Link to comment https://forums.phpfreaks.com/topic/54248-form-arrays-in-javascript/#findComment-268581 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.