//I want to print selected information from selection of select box. But I don't know why the function 'print_info' doesn't work in my code. I think there's a problem in print_info's div tag because I can't see color icon next to the 'background-color'. Please let me know where should I fix.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body style="text-align: center; background-color:#9191e988">
<div style="position: absolute; left: 60px; border:white; background-color:white; padding:10px;">
<p><font size="2">Select route</font></p>
<form>
<select name="number" id="NUM" onchange="changenumSelect(this.value)">
<option value=""disabled>select num</option>
<option value="n1"selected>n1</option>
<option value="n2">n2</option>
<option value="n3">n3</option>
</select>
</form>
</div>
<script> function chageRouteSelect(r){
if (r=="n1")
print_info(11, 22, "a", "b", 33);
else if(r=="n2")
print_info(44, 55, "c", "d", 66);
else if(r=="n3")
print_info(77, 88, "e", "f", 99);
</script>
<script> function print_info(num1, num2, stp1, stp2, dist){
<div style="position: absolute; left: 60px; top: 70px; border: 5px; background-color:white; padding:20px;">
<font size="5">main number</font>
document.write("about ".bold()+num1+"<br/>".bold());
document.write("sub number "+num2+"<br/>");
document.write("begin: "+stp1+"<br/>↕<br/> end: "+stp2+"<br/>");
document.write("distance: "+dist+"km");
</div>
}
</script>
</body>
</html>
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment