Solved

Javascript issue

Posted on 2014-04-15
1
115 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 10

Accepted Solution

by:
Jeffrey Dake earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

803 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