Use jQuery to get values of dropdownlists in an html table column for each row
Posted
by Arnold
on Stack Overflow
See other posts from Stack Overflow
or by Arnold
Published on 2010-05-26T12:58:41Z
Indexed on
2010/05/26
13:01 UTC
Read the original article
Hit count: 399
jQuery
Hi All,
I have a requirement to build a simple html table of memos. The table consists of n-rows each with 2 columns: (1) a dropdownlist of types of memos and (2) the text of a memo - a textbox.
I have successfully implemented jQuery to allow the user to Add a new row. That entails the selecting of a type of memo and then typing something into the textbox.
I've also implemented jQuery to allow the user to mark a memo row for deletion.
This is a partial view and the Save is handled by a container page.
Requirements stipulate that there can be only one type of memo in the table. What I would like to be able to do is this: When the user clicks the Add button to add a new row (after having selected the memo type and entered some text into the textbox) I want the code to first examine each row in the table getting the value for each memo type dropdownlist. If the newly entered dropdownlist value is the same as one previously entered, I want to abort the add row process.
Requirements also stipulate that all dropdownlists remain enabled to allow the user to change the memo type at any time. Similarly, I would like to be able to scan the table checking to see if that same memo type has already been entered.
What would the jQuery look like for this kind of validation?
Thanks!
Arnold
© Stack Overflow or respective owner