I'm scratching my head over this one.
HTML:
<form>
<input name="changes" type="radio" value="2012-05-18T16%3A53%3A00.000000000000%2B0100">
<span>2012-05-18 16:53:00 +0100</span>
<input name="changes" type="radio" value="2012-05-29T16%3A51%3A00.000000000000%2B0100">
<span>2012-05-29 16:51:00 +0100</span>
<input name="changes" type="radio" value="2012-05-31T17%3A30%3A00.000000000000%2B0100">
<span>2012-05-31 17:30:00 +0100</span>
<input name="changes" type="radio" value="2012-06-01T16%3A30%3A00.000000000000%2B0100">
<input id="view-change" type="button" value="View">
</form>
In the Chrome JavaScript console:
var today = "2012-05-18T16%3A53%3A00.000000000000%2B0100"
$('input[value="2012-05-18T16%3A53%3A00.000000000000%2B0100"]') -> Finds object
$('input[value=today]') -> Nothing
Huh? Why can't i select the input using a var?
PS. Ive confirmed, jQuery.type(today) = string
Try:
$('input[value="'+today+'"]')
See jsfiddle
You should do that like this:
$('input[value="' + today + '"]');
In php you can just insert vars into a string and they will be substituted with their values, but not in javascript. You need to concatenate the string part with the contents of the variable to make it work. Now you are just looking for an input with a value of (literally) 'today', not the contents of the var 'today'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With