I’d like to give this code conditions during the validation process of the form .. If the ESN list text field input value is in the range of 1000 to 3000 , I’d like the drop down to automatically select STM3 below , if the range of the number input is between 5000 and 9000 , I’d like Trackpack option from the drop down to automatically populate after a user for example input 6000 on the text input field because it is between 5000 and 9000 ..
Q: How can I trigger the dropwn menu after typing a number on the text field based on a condition , like ranges between numbers that will trigger one of the dropdown options from the select tag?
<html>
<head> <title> Form </title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript">
$(':submit').click(function(e) {
$(':text').each(function() {
if($(this).val().length == 0) {
$(this).css('border', '2px solid red');
}
});
e.preventDefault();
});
</script>
</head>
<body >
<form id="provision">
ESNList: <input type="text" id="ESNList" name="ESNList" size="30" /> <br />
ESN Start:<input type="text" id="ESNStart" name="ESNStart" size="10" /> <br />
ESN End: <input type="text" id="ESNStart" name="ESNStart" size="10" /> <br />
UnitName:<input type="text" id="STxName" name="STxName" size="30" /> <br />
Unit Model: <select name="STxName">
<option value="stx2">STX2</option>
<option value="protopak">Protopak</option>
<option value="stm3" selected>STM3</option>
<option value="acutec">Acutec</option>
<option value="mmt">MMT</option>
<option value="smartone">Trackpack</option>
<option value="smartoneb" >SmartOneB</option>
<option value="audi">Acutec</option>
</select> <br />
RTU Model Type:
<select name="rtumodel">
<option value="globalstar">GlobalStar</option>
<option value="both">Both</option>
<option value="comtech">Comtech</option>
<option value="stmcomtech">STMComtech</option>
</select> <br />
<input type="submit" value ="submit" />
</form>
</body>
</html>
You can accomplish this with the setInterval function. I recommend you do some reading up on it here: http://www.w3schools.com/jsref/met_win_setinterval.asp
In addition, you may find your solution here on jsfiddle: http://jsfiddle.net/PCB5d/
Subsequently however here is the code:
I hope this helps