Hello,
I am trying to setup a simple data entry form and I am new to JQUERY. I need to return my database ID of the select autocompleted item in a hidden field. I found the code online to this, but when I added multiple fields to the form, autocomplete worked by changing the reference from ID to a CLASS. But the hidden fields did not.
I believe the issue is that I need to have the specific ID tag name to update the value for the specific hidden field. I was thinking I could do something like get the ID of the current field that is being updated with the autocomplete...that is where I need some help.
Code:
$().ready(function() {
$(".course").autocomplete("get_course_list2.php", {
width: 360,
matchContains: true,
mustMatch: true,
//minChars: 0,
//multiple: true,
//highlight: false,
//multipleSeparator: ",",
selectFirst: false
});
$(".course").result(function(event, data, formatted) {
$("#course_val").val(data[1]);
});
});
Here is the HTML form
Code:
<form autocomplete="off">
<p>
Course Name <label>:</label>
<input type="text" name="course1" class="course" id="course1" />
<input type="hidden" name="course_val1" class=".course_val" id="course_val1" />
</p>
<p>
Course Name <label>:</label>
<input type="text" name="course2" class="course" id="course2" />
<input type="hidden" name="course_val2" class=".course_val" id="course_val2 " />
</p>
<input type="submit" value="Submit" />
</form>
I would appreciate any help provided.
Thanks
jlimited