Im vey new to php. How to pass the selected drop box value to next page url? I have something like this:-
<script language="javascript">
function showMe(str)
{
document.getElementById('myDiv').innerHTML = 'You have selected :'+str;
}
</script>
<select id="ccrseid" name="ccrseid" onchange="showMe(this.value);">
<option value="">Select</option>
<option value="1">Computer Science</option>
<option value="2">Engineering</option>
<option value="3">Business</option>
<option value="4">Education and Training</option>
</select>
<div id="myDiv"></div>
</body>
</html>
<a href="#"onclick="document.location.href='timer.php?selectvalue='+document.getElementById('myDiv').value">Submit</a>
when i execute im getting “undefined” at the url .
http://localhost/timer.php?selectvalue=undefined
how do i solve this?
With your question, there seems like there are two different outcomes you want to achieve; the first being that you want to pass the value of the
<select>dropbox to the landing php page, while your example code suggests that you want to pass the<select>value with appending “You have selected :” to it.So basically – with the given information – there are two outcomes you want to achieve, the first being the final “GET” url being
And the other with the “GET” url being
With the first outcome, using javascript is a bad way of approaching this, I suggest to you to use the standard html
<form>tag to build your form and<input>instead of the<a>tag as a buttonWith the second solution, that being to print the
<select>value into a div and send that data to the landing page with a<a>tag, what you need to do is to to change the link on the last lineto