Solved

Javascript issue

Posted on 2014-04-15
1
106 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
Comment Utility
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 Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

771 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

11 Experts available now in Live!

Get 1:1 Help Now