1
What is the possibility of reusing $.change ?
Guys, I have a problem. I need on the same page to use
several changes in several selects. Here’s how it works: First change: User chooses in select 1
change runs and a get json search via Json in the URL and shows the result.
Second change : User chooses in select 2 (which is different from select 1) The change runs and m get json search via Json at the second URL and shows the result.
The problem is:
When I run each change on separate pages Perfect wheel.
But when I turn on the same page, it doesn’t work. What I need to do to make all changes (I will have more than 2) run on the same page.
That’s how I got the Jquery documentation >
$( "select" ).change(function () {
var str = "";
$( "select option:selected" ).each(function() {
str += $(this).val() + " ";
});
console.log(str);
var url = "http://minhaurl.com/json?cidade="+str;
$.getJSON( url, function( data ) {
Json rodando perfeito.
});
})
.change();
I just repeat the function by changing the URL, STR, and select parameters.
There are other ways to achieve the same effect as change. And that I can repeat on the same page ?
NOTE: Each select has your ID. Each selector that receives the values has your ID.
Thank you, hugs
OBS 2: I don’t intend to join them, They are separate.
Each has its URL, and has its answers.
To help [http://pastebin.com/LVQa4HAU][1]
I’m quite a beginner. So I don’t know much.
You want to join all the values of all
selects
selected in the same str and pass to URL?– Randrade