I want to be able to submit the form only if the 'my val 2' option is selected. If another option is selected and the submit button is pressed, I want it to just say they cannot submit it. Also, if they submit it, I want it to go to a submission page that says what they submitted. Here is my form:
<form action="formSub.php" method="POST" name="myform" onsubmit="return checkscript()">
<select name="test_select">
<option value="1">my val 1</option>
<option value="2">my val 2</option>
<option value="3">my val 3</option>
<option value="4">my val 4</option>
</select>
<input type="submit" value="Submit" name="test_button" onClick="submitform(test_select.value)">
</form>
Here are my javascript functions
function submitform(val) {
var obj = val;;
alert("Value = " + obj);
}
function checkscript() {
if (obj !== "2") {
alert('This is not \'my val 2\' so you cannot submit');
return false;
}
return true;
}
Also, my checkscript function doesn't work correctly. The f statement is always false.