So it’s like I have a selectbox, with while loop as option as I want to bring out the options from database, is it possible to click on the option and link?
The while loop is like this
while ($row = mysqli_fetch_assoc($result0)) { $option .= '<option value="'.$row['id'].'">'.$row['Font_Family'].'</option>'; }
This is the select box
<select id='font' style="width:100px;" onchange="autosubmit();"> <option value ="0">Select</option>
But on clicking the option I want to link it to
font.php?id={id that is being pointed to}
How can I do this?
Advertisement
Answer
Use Javascript to call the onchange.
Between the header tags, put:
<script type="text/javascript"> function autosubmit() { window.location="font.php?id="+document.getElementById("font").value; } </script>
View the working jsbin: http://jsbin.com/uwuyoz/1/
Please note, you’ll have to uncomment the window.location. I simply have it ‘alerting’ now. But all the code is there.