2
I have a script that checks the difference between two sets of dates, and I want when one of these differences is greater than the other, that the value
previously chosen from a certain select
change.
How an excerpt of code is worth a thousand words:
if (daysc > daysb) {
$("#var1").show();
$("#var2").hide();
$("#var3").val('mudaestevalor');
}
But it’s not working. I have another function after this, which opens a div
only if $var3
have a certain value:
if ($('#var3').val() == 'mudaestevalor')
{
abre div
}
But she’s not changing with .val()
. I tried other variants, looked at some answers from here and of Soen and nothing. Some variants I tested:
$("select#var3").trigger("mudaestevalor");
$("select#var3 option").val('mudaestevalor').change();
$("select#var3 option").val('mudaestevalor');
Minimum example in fiddle: http://jsfiddle.net/gustavox/axwxbyx6/2/
Their
<option>
have the attributevalue
?$("#var3").val('mudaestevalor');
is the right way– bfavaretto
Can you put HTML too? if you do a jsFiddle it will be solved in a few minutes :)
– Sergio
Yes you have @bfavaretto... Thanks, I’ll make a fiddle...
– gustavox
Yes @Sergio will do it right now! :)
– gustavox
select must have an option with
value="mudaestevalor"
.– KaduAmaral
I did some tests here and in fact it didn’t work '-' if anyone wants to test, I need to leave: https://jsfiddle.net/fyoxwzso/
– KaduAmaral
@Kaduamaral joined Event Handler after changing select :P so it wouldn’t work ... -> https://jsfiddle.net/fyoxwzso/1/
– Sergio
I don’t know if it’s enough, but I put only one condition 2 > 1 to test (instead of dates), and if you notice, it even puts the value already in select, but it doesn’t open div...) http://jsfiddle.net/gustavox/axwxbyx6/2/ @bfavaretto
– gustavox
haeuhuahueuae didn’t even call me @Sergio was hungry wanting to come away eating kk
– KaduAmaral