I have a select element, and two text boxes. When the user clicks a list option, the id and names (text) get populated in those two text boxes.
I want to be able to update the text portion of the select by the click of a button, making sure to update that of the id reflected in the text box. Here's what I've been working with:
HTML:
<select name="categories" id="categories" multiple> <option value="1">Baby pictures</option> <option value="2">Animals</option> <option value="3">Nature</option> </select> <input type="text" name="catID" id="catID" /> <input type="text" name="selCat" id="selCat" /> <input type="button" id="update" value="update" /> jquery:
$('#update').click(function() { var selID; var selCat; selID = $('#catID').val(); selCat = $('#selCat').val(); $('#categories').val(selID).text(selCat); }) I've tried several different things - this is the only one that actually has an effect on the list itself. Although, it completely empties it. heh
Any help would be appreciated.
#categoriesis a form field,.valwon't work. What are you using the "id" stuff for? I don't understand what that value is to be used for