[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Javascript issue

Posted on 2014-04-15
1
Medium Priority
?
135 Views
Last Modified: 2014-04-18
See attached file

It winds up putting in qs (the query string being passed) EVERY checkbox element on the form; I only want the UNCHECKED ones.

I suspect the code if (! en.checked) is in error.

How can I fix this?
                        }
chk-vals.js
0
Comment
Question by:Richard Korts
1 Comment
 
LVL 11

Accepted Solution

by:
Jeffrey Dake earned 2000 total points
ID: 40003014
Looks like you are setting your en variable equal to the name of the checkbox instead of the checkbox itself.  Try changing your if statement to check e.checked instead of en.checked.

function chk_vals() {
				if (ac == "m") {
					 window.location = "admin_menu.php";
					 return false
				}
				ne = document.st.elements.length;
				qs = "";
				for (i = 0; i < ne; i++) {
					e = document.st.elements[i];
					if (e.type == "checkbox") {
						en = e.name;
						if (!e.checked) {
							if (qs == "") {
								qs = "?" + en + "=u";
							} else {
								qs = qs + "&" + en + "=u";
							}
						}
					}
				}		
				if (ac == "a") {
					document.st.action = "updt_base_citylinks.php" + qs;
					 return true;
				}	

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

831 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