function change(x)
var str=x;
<?php $name=?>str;
<?php echo $name;
<select name="customers" onchange=change('this.value')>
<option>Phani Varma</option>
<option>Prabhas Varma</option>
<option>Kishore Varma</option>
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

Recommended Answers

All 3 Replies

place a value attribute inside option tag

<?php $name=?>

This piece of code will generate an error since it is not complete.

To pas a JS function value to PHP the JS function should return the value first. Then the value could either be
1. set into a form element (maybe a hidden input) and the form posted to the server or
2. sent to the server by ajax

Hope I understood the question. Could you explain more what you want to achieve, please.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.