0
<html>
<head>
<script>
function change(x)
{
var str=x;
<?php $name=?>str;
}
</script>
<?php echo $name;
</head>
<body>
<form>
<select name="customers" onchange=change('this.value')>
<option>Varma</option>
<option>Phani Varma</option>
<option>Prabhas Varma</option>
<option>Kishore Varma</option>
</select>
</form>
</body>
</html>
so when ever user change the select,the value should be passed to php & it must be echoed by php.Lots of thanks To all
3
Contributors
2
Replies
12
Views
4 Years
Discussion Span
Last Post by radhakrishna.p
0

place on the onchange attribute to the option tag attribute and on the option tag attribute place s value attribute..

<select name="selected"><option value="first value" onChange="change(this.value)">first value</option></select>

or you can have it this way

<select name="selected" onChange="change(this.value)"><option value="first value" >first value</option></select>

either way it will be the same

Edited by masterjiraya

0

hai Venter,

can you explain me a little bit more about whats your actual requirement is?

i am getting little bit confustion about your requirement.

so i have modified your code what i understood from the post which is given below

have a look at once. after changing the valus of drop down box the page is redirected to Requirement.php page

there you can echo your selcted value this is also given in the below of the code.

<html>
<head>
<script type="text/javascript">
function change(select_id)
{
    // getting values into java script from the dropdown box in html

    var CustomersSelect = document.getElementById(select_id); 
    var customer_name = CustomersSelect.options[CustomersSelect.selectedIndex].text;

    document.location.href ="Requirement.php?my_val="+customer_name;
}
</script>
</head>
<body>
<form>
    <select name="customers" id="customers" onchange="change(this.id)">
        <option>Varma</option>
        <option>Phani Varma</option>
        <option>Prabhas Varma</option>
        <option>Kishore Varma</option>
    </select>
</form>
</body>
</html>

at Requirement.php you need to get the selected value by using $_GET['my_val'] for echoing the value

let me know whether this is what you expected or not

happy coding

Edited by radhakrishna.p: giving clarity on the solution

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.