开发者

jquery load function problem

开发者 https://www.devze.com 2023-02-01 04:17 出处:网络
i have a select box like that <select name=\"sehirler_post\" id=\"sehirler_post\"> i am getting values via jquery. i know two different ways to get values.

i have a select box like that

<select name="sehirler_post" id="sehirler_post">

i am getting values via jquery. i know two different ways to get values. first one is :

var sehirler_post = jQuery('select#sehirler_pos开发者_JS百科t').attr('value');

second one is:

jQuery('#sehirler_post ').val()

and finally here is my problem, i have something like this:

jQuery("#okay").load("ajax_post_category.php?okay="+id+"");

i would like to use selectbox value instead of id (okay="+id+"). so, i must change +id+ part with select box value. however i can not do it.. i tried to do like that:

jQuery("#okay").load("ajax_post_category.php?okay="+jQuery('#sehirler_post').val()+"");

it did not work. there must be a way, so i can use selectbox value instead of id in my load function. if anyone helps me, ill be so glad.

regards


#selectList is not the id of your select box, hence change it to

jQuery("#okay").load("ajax_post_category.php?okay="+jQuery('#sehirler_post').val()+"");

can you bread it into two line of code and try

var loadUrl="ajax_post_category.php?okay="+jQuery('#sehirler_post').val();
jQuery("#okay").load(loadUrl);


You want to do somthing like this:

jQuery("#okay").load("ajax_post_category.php?okay=" + jQuery('#sehirler_post :selected').val());

This looks at your select element and finds the child that has been selected (which should only be one). Then it returns the value.


var id = $("#sehirler_post").val();

0

精彩评论

暂无评论...
验证码 换一张
取 消