Reputation: 23
Please can help. How can the variables passed. I have function for select option
Example jquery:-
var one = '1';
var two = '2';
$(document).ready(function(){
$(#).change(function(){
if(one == '1'){
var one = 'hello';
}
});
$(#).change(function(){
if(two == '2'){
var two = 'world!';
}
});
if (one =='hello' && two =='world!'){
$(#welcome).hmtl("hello world!")
}
});
Upvotes: 1
Views: 84
Reputation: 23
Thanks very much for your answers
I have found
my example code:-
$(document).ready(function(){
var one, two;
$("#item_select1, #item_select2").change(function(){
one = $("#item_select1").val();
two = $("#item_select2").val();
if (one =='1' && two == '2'){
$("#welcome").html("hello world!");
}
if (one =='1' && two == '1'){
$("#welcome").html("");
}
if (one =='0' && two == '0'){
$("#welcome").html("Goodbye!");
}
});
});
Upvotes: 0
Reputation: 3543
Use this function:
$(document).ready(function(){
radio = $('.radioid option:selected').val();
if( radio == 1 )
alert(1);
...
});
Upvotes: 0
Reputation: 21449
you should declare the variables as globals to be able to access them from everywhere in your code and you should not redeclare them using var keyword:
$(document).ready(function(){
var one, two;
$("selector").change(function(){
if(one == '1'){
one = 'hello';
}
});
$("selector").change(function(){
if(two == '2'){
two = 'world!';
}
});
if (one =='hello' && two =='world!'){
$(#welcome).hmtl("hello world!")
}
Upvotes: 1