troubleshooting Question

Get Values of Radio buttons/Checkboxes - ajax/javascript.

Avatar of harris9999
harris9999Flag for United Kingdom of Great Britain and Northern Ireland asked on
AJAXJavaScriptWeb Development
19 Comments1 Solution1028 ViewsLast Modified:
I have a form with a number of radio buttons / checkboxes on it.  
When they are clicked on the results are displayed on the main part of the page.

each radio button has an onclick event:

onClick="updateItems(this.form);return false;"

My function receiving this is below.  

To get the values of the radio buttons I tried the document.getElementsByName but it doesn't work, they return as undefined.

How can I get the values of the radio buttons / checkboxes?

occasion and onoffer are checkboxes, the rest are radio buttons.
function updateItems(formElement)
{	
show_progressbar('shopdiv');

	
xmlhttp2=GetXmlHttpObject();
if (xmlhttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="/shop/includes/updateitems.asp";
var i=0;
url=url+"?cmd=1";

var catid=document.getElementsByName('category').value;
url=url+"&catid="+catid;
var brandid=document.getElementsByName('brand').value;
url=url+"&brandid="+brandid;
var rangeid=document.getElementsByName('range').value;
url=url+"&rangeid="+rangeid;
var occid=document.getElementsByName('occasion').value;
url=url+"&occid="+occid;
var priceid=document.getElementsByName('price').value;
url=url+"&priceid="+priceid;
var onoffer=document.getElementsByName('onoffer').value;
url=url+"&offer="+onoffer;


url=url+"&sid="+Math.random();
xmlhttp2.onreadystatechange=showShopitems;
xmlhttp2.open("GET",url,true);
xmlhttp2.send(null);

}

Open in new window

ASKER CERTIFIED SOLUTION
leakim971
Multitechnician
Join our community to see this answer!
Unlock 1 Answer and 19 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros