Having trouble getting JQuery to access the parent form field ‘inputStart’s value when a new value is chosen from the select field named inputStartMonth
What is strange is similar syntax is working elsewhere on the same site. I’m using the input’s name and class because I repeat the same form (with a different id) multiple times on the same page.
Any suggestions would be greatly appreciated.
Below is the jquery code:
$('input[name=inputStartMonth]').change(function() {
var month = $(this).val();
$(this).parent().find('input[name=inputStart]').val(month);
});
Partial HTML:
<td><input name="inputStart" type="text" autocomplete="off" value="May '96">
<div class="startDateDrop hideThis dropForm">
<select name="inputStartMonth">
You have a couple problems. One, as others have mentioned, the parent of your select is a div, which is not the parent of your input. Second, your selector is using $(‘input[name=inputStartMonth]’) it should be “select” not input. See: http://jsfiddle.net/sYFuY/