Solved

Enter only New Table Rows

Posted on 2010-11-15
2
300 Views
Last Modified: 2012-05-10
Now I need to make sure that I only enter each combination of select option and checkbox value once into the table and not multiple times. I am thinking I need to use contains().

Any help will save me time.

Thank you
sshivanna
0
Comment
Question by:sshivanna
2 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 34136662
you need not search each and every value in the table. Just make sure that you give the id value of a  row based on the value of checkbox value, so that before adding the value in table you just need to check if an element based on that value exists or not, ie

if the value of selected checkbox is val1, then make sure that it always goes in row of id value tr_val1, so before creating a new row, just check if an element exists with the same name, by
var element = document.getElementById("tr_"+checkBoxValue);
if (element == null)
{
   alert("element does not exists, so this value is not in the table now");
}

hope this helps
0
 
LVL 2

Author Comment

by:sshivanna
ID: 34136930
That worked perfectly. Thank you.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now