php - AJAX/Jquery Store dropdown value in variable -


in script have following:-

<script>        $("#country").on("change", function(){          var selected = $(this).val();          $("#results").html("<div class='alert-box success'><span><img src='images/shipping_ukrm.jpg'></span> <b>&pound" + selected + " plus packaging</b></div>");  		$('#frmelement').val(selected);        })      </script>

i select country in turn gets value of option value in dropdown select field, want store dropdown value country name in variable pass , use within form

anyone help

this select dropdown box information

echo '<select name="country" id="country" class="span5" />';  	echo '<option value="0" selected>select country</option>';  	mysql_connect("$host", "$username", "$password")or die("cannot connect");  	mysql_select_db("$db_name")or die("cannot select db");  	$sql1 = "select c.country_id,c.name,pr.price,pr.weight,pr.weight1,pr.class,c.zone country c left join postagerates pr on pr.class = c.zone (pr.weight <= '$totweight' , pr.weight1 >= '$totweight') order c.name asc";  	$query1 = mysql_query($sql1);  	while ($row2 = mysql_fetch_array($query1)) {   	echo '<option value = "'.money_format('%.2n', $row2["price"]).'">'.$row2["name"].'</option>';  	}  		echo '</select>

try this:

var selected = $(this).find('option:selected').text() 

see fiddle


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -