Friday, 15 June 2012

javascript - Activating radiobutton upon typing in text box -



javascript - Activating radiobutton upon typing in text box -

question follow-up on activate radiobutton when text box selected quite old.

i've taken code accepted reply , adapted page. works in jfiddle (i copied bits page in jfiddle testing), doesn't work in page. more digging figured have add together called jquery, did. still doesn't work.

importing jquery in head section of html:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

relevant code snippet page:

<script> $('#sourcetext').on('keyup', function() { $('#sourcecheck').prop('checked', !!this.value.length); }); </script> <p><input type="radio" name="source" id="sourcecheck" value="meetup" /> meetup, group: <input type="text" name="meetupgroup" id="sourcetext" value="" /></p> <p><input type="radio" name="source" value="facebook" checked /> facebook</p> <p><input type="radio" name="source" value="timeout" /> time out magazine</p> <p><input type="radio" name="source" value="hkmagazine" /> hk magazine</p> <p><input type="radio" name="source" value="other" /> other: <input type="text" name="sourceother" value="" /> </p>

now question: perchance doing wrong here?

place <script> tags containing code @ bottom of markup - or wrap code in dom ready function:

$(document).ready(function() { //your code here });

javascript jquery html forms

No comments:

Post a Comment