Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML drop down box redirect

just putting together a simple html webpage and i wanted to add a drop down box where i would select an option and it would bring up text depending on what was selected.

I have this so far. I know i would probably have to use javascript but i dont know where to start.

<html>
<head>
<title> My webpage </title>
</head>
<body>
<h1> Times Tables! </h1>
<p> Click on the drop down box to select the tables you want to see </p>


<select>
<option value="Please select">Please select</option>
<option value="1x0 =0 1x1 =1 1x2 =2 1x3 =3">1 time table</option>
<option value="2 times table">2 times table</option>
<option value="3 times table">3 times table</option>
<option value="4 times table">4 times table</option>
<option value="5 times table">5 times table</option>
<option value="6 times table">6 times table</option>
<option value="7 times table">7 times table</option>
<option value="8 times table">8 times table</option>
<option value="9 times table">9 times table</option>
<option value="10 times table">10 times table</option>
<option value="11 times table">11 times table</option>
<option value="12 times table">12 times table</option>

</select>
<p>
</p>

</body>
</html>

Thanks

like image 842
Arianna.Ellen Avatar asked Mar 17 '26 03:03

Arianna.Ellen


1 Answers

You're right that you want to use JavaScript. In fact, using jQuery would be even better for the event handling.

If you create a function $('#selectID').on('change', function(){}); (You'll have to give your select and id to identify it by) Then inside the function parentheses write the code to do what you want. In your case if it's to display some form of text you could just
alert($('#selectID').val()) or just jQuery to alter the DOM

like image 200
Adam Brocklehurst Avatar answered Mar 18 '26 18:03

Adam Brocklehurst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!