php - Get selected text from combox to a variable -
i want select school year combobox , use search classes letter year selected. need put selected text variable.
$yeardb = "select distinct `year` `class`"; $do_year = mysqli_query($connectdb, $yeardb); $num_year = mysqli_num_rows($do_year); year: <form method="post" > <select id="yearcb" name="year" onchange="document.getelementbyid('selected_text').value=this.options[this.selectedindex].text"> <?php ($i=0; $i<$num_year; $i++) { $yr = mysqli_fetch_array($do_year); echo'<option value="'.$i.'">'.$yr ['year'].'</option>'; } ?> </select> <input type="hidden" name="selected_text" id="selected_text" /> </form> <?php if(isset($_post['selected_text'])) { $value = $_post['year']; $make = mysql_real_escape_string($_post['selected_text']); } $classdb = "select `class` `classes` `year` =".$make; $do_class = mysqli_query($connectdb, $classdb); $num_class = mysqli_num_rows($do_class); ?>
in jquery
<select id="yearcb" name="year" onchange="funname(this.value)"> </select> <input type="hidden" name="selected_text" id="selected_text" /> function funname(val) `/*function set value*/` { $("#selected_text").val(val); }
Comments
Post a Comment