glennn.php Posted August 12, 2011 Share Posted August 12, 2011 please, someone (anyone), i need to pass a select/option value to a php variable within the same page somehow using onChange. i've tried to find a similar configuration in these forums and netwide, but haven't been able to. should be simple. i just don't know jquery or ajax at ALL: <form id="catform" > <select id="cat" onChange=""> <option>Choose Category</option> <option value="Social Life">A Social Life</option> <option value="Movies - TV - Music">Movies - TV - Music</option> </select> </form> <div id="divid"> $cat = "cat selection"; </div> p.s. If there's a way to run a function from this same onChange event, that'd be pretty nice, too. I'm figuring to tackle that next. thanks VERY much in advance, gn Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/ Share on other sites More sharing options...
AyKay47 Posted August 12, 2011 Share Posted August 12, 2011 use jquery.. http://api.jquery.com/category/ajax/ Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256521 Share on other sites More sharing options...
glennn.php Posted August 12, 2011 Author Share Posted August 12, 2011 right, that's what i want to do, but as i said, "i just don't know jquery or ajax at ALL". i'm asking for a little help doing this. i realize that the form value has to leave the page and return via a div, but that's all i know. i don't know jquery. i'm humbly asking for help. gn Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256527 Share on other sites More sharing options...
AyKay47 Posted August 12, 2011 Share Posted August 12, 2011 you're asking for me to write the code for you, which I don't feel like doing.. however i will anyway.. $(function(){ $("#cat").change(function(){ var value = this.value; $.ajax({ url: "url.php", data: "value="+value, success: function(){alert("success!")} }); }); }); Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256529 Share on other sites More sharing options...
glennn.php Posted August 12, 2011 Author Share Posted August 12, 2011 i have an ENORMOUS amount of gratitude for the MANY people in forums, and especially this one, from who'm i've learned a GREAT deal about PHP and MySQL, and to whom i can credit my delight in my chosen (and fairly successful) occupation. in return i tell many other people who are attempting to learn of my experiences with most helpful people in these forums, and encourage them to use them. i ALSO gladly offer what assistance i can when there is someone asking for help which i can offer. This is how i've learned more than half of what i know. By someone 'writing the code for me'. i don't just copy and paste and be done with it. I've learned from ALL of it. I also tell these newer and eager persons that there are, occasionally, grouches who for some reason are in here to simply grumble and pretend to help, taking a lot of the joy of this poetry called code out of the whole equation. They seem to want to make it difficult for others who are really here to try to learn something, making others wonder why they're really in here at all. This is what makes me hesitant to want to ask anyone what the heck i'm supposed to do with that code that you so kindly wrote for me. i stuck it in the page in more than one place, and it preformed nothing. i don't know if i'm supposed to use a GET or POST to retrieve my value, because it didn't open a url.php (yes, i created one) for me to SEE what i'm supposed to do. I really am sorry to have bothered you, AK, and i surely hope that you're not too bitter over choosing to do someone else's work for them. I guess i'll go ask for help somewhere else and hope not to bother someone else too much. also, i think your tenses are mixed in your signature. Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256540 Share on other sites More sharing options...
AyKay47 Posted August 12, 2011 Share Posted August 12, 2011 I am going to ignore 95% of your post, since I did help you.. the default type is the GET type, however you can change this by adding the type: setting.. to what you said, you said you learn by looking at code basically.. now the link I provided you with is a link to the jquery ajax API documentation which has absolutely everything that you will need to answer your own question.. however all you wanted was the code.. now to me this demonstrates not someone who wants to learn, rather someone who is too lazy to read and learn by themselves and needs their hand held the entire way.. im done helping you.. Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256544 Share on other sites More sharing options...
glennn.php Posted August 12, 2011 Author Share Posted August 12, 2011 rather, someone who's busy trying to help someone else get a project finished by tomorrow and who doesn't even know where to start reading in all that in the link you sent me, much less have the time (i've spent an entire day trying to find something similar). when i see code work, i see how it works. as i said, i don't just copy and paste and forget about it. you're just a fucking grouch, admit it. the kind of help you offer people have to work around. Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256547 Share on other sites More sharing options...
glennn.php Posted August 12, 2011 Author Share Posted August 12, 2011 I am going to ignore 95% of your post, since I did help you.. the default type is the GET type, however you can change this by adding the type: setting.. to what you said, you said you learn by looking at code basically.. now the link I provided you with is a link to the jquery ajax API documentation which has absolutely everything that you will need to answer your own question.. however all you wanted was the code.. now to me this demonstrates not someone who wants to learn, rather someone who is too lazy to read and learn by themselves and needs their hand held the entire way.. im done helping you.. and God Bless. Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256548 Share on other sites More sharing options...
AyKay47 Posted August 12, 2011 Share Posted August 12, 2011 my first post solved your question.. P.S dont bite off more than you can chew.. shouldnt have agreed to help someone when you have no clue what you are doing, and expect volunteers to do the work for you.. Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256549 Share on other sites More sharing options...
glennn.php Posted August 12, 2011 Author Share Posted August 12, 2011 your function does not work as you've posted it. if there's something you've failed to mention, then you've proven my point. Quote Link to comment https://forums.phpfreaks.com/topic/244633-ok-ill-try-the-question-this-way/#findComment-1256558 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.