0

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_post').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

2
  • 1
    Rather than state that "it did not work" in your original question, and "it did not work" in response to the answers you've gotten, perhaps you might want to elaborate a bit and describe how it's not working? Are you getting an error? If so, what's the error. The more info you can provide, the greater chance you have of getting the "right" answer. Commented Dec 28, 2010 at 5:44
  • I concur. Saying "it didn't work" doesn't work. Perhaps you can debug this trying to build the url outside your load method. Something like url = someString + someValue and then do console.log(url). Tell us what you get Commented Dec 28, 2010 at 6:00

3 Answers 3

2

#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);
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for your kindly reply. however it did not work. thanks
no, did not work. however it works if i write ?okay="+5 instead of ?okay="+jQuery.... well, it works if i write a number with my hand. it cant get numbers from select box value via jquery and load the new page. thats my problem.
0

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.

Comments

0

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

1 Comment

thanks for your reply. your answer was a clever idea. i tried it, however it did not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.