Solved

Javascript issue

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

688 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