Friday, 15 May 2015

javascript - Getting values from selected option in select menu and repeat them in similar selected menus Java Script, PHP -



javascript - Getting values from selected option in select menu and repeat them in similar selected menus Java Script, PHP -

i have next select menu repeated 8 times php loop. want, using js, set onchange event repeat selected alternative first menu in rest of 7 menus, , off course of study repeat value of alternative well. given read select menu values mysql table:

for ($a=1; $a<=$n; $a++) { readtable_no_order ("rooms"); //php function read table echo '<select name="hoffers['.$a.']'.'" class= "select">'; echo '<option value="" selected="selected"></option>'; while ($row=mysql_fetch_array ($result)) {echo '<option value ="'. $row['room'] . '">'. $row['room'] . '</option>';} echo '</select><br>'; }

thanks in advance.

change html

<select name="rooms" class="rooms"> <option value="single">single</option> <option value="double">double</option> <option value="triple">triple</option> </select>

and add together js:

elements = document.getelementsbyclassname('rooms'); (i=0; i<elements.length; i++) { elements[i].onchange = function() { (i=0; i<elements.length; i++){ elements[i].value = this.value; } } }

javascript php

No comments:

Post a Comment