?
Solved

Javascript issue

Posted on 2014-04-15
1
Medium Priority
?
128 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
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…
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

764 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