I have following scripts:
<!DOCTYPE html>
<HTML>
<HEAD>
<META charset="UTF-8">
<SCRIPT src="scripts2.js"></SCRIPT>
</HEAD>
<BODY>
<FORM>
<SELECT name="receipt" onchange="set_input_value()">
<OPTION id="P" value="P">P / </OPTION>
<OPTION id="b" value="b">b / </OPTION>
</SELECT>
<INPUT type='text' id='id1' />
</FORM>
</BODY>
</HTML>
and
function set_input_value(){
if(document.getElementById('P').value=='P'){
document.getElementById('id1').value='1';
}
if(document.getElementById('b').value=='b'){
document.getElementById('id1').value='2';
}
}
I want to make something like. If I choose option 'P' set the value of the input on 1. If I choose option 'b' set the value of the input on 2.
Sorry, if it has been solved somewhere, but I didn't find it. Thanks for help.
javascriptand notjava.set_input_valuebad? Looks like a style decision, to me. It has no impact on how it works.