Problem with Radio Button error "[object HTMLInputElement]"

Thread Solved

Join Date: Mar 2008
Posts: 36
Reputation: lonestar23 is an unknown quantity at this point 
Solved Threads: 0
lonestar23 lonestar23 is offline Offline
Light Poster

Problem with Radio Button error "[object HTMLInputElement]"

 
0
  #1
Sep 5th, 2008
Hello,

I am having problems retrieving correct values from two radio buttons in my AJAX script below.

The radio button values are either a 1 or 0 and always produces 0 regardless of which button is selected.

Once in AJAX, I can not have the script retreive a 1 or 0. AJAX script produces "[object HTMLInputElement]" as the response. Not sure what is going wrong.

Thanks in Advance.
Diego

  1. <script type="text/javascript">
  2. var settings = getXmlHttpRequestObject(); function saveCar() {
  3. if (settings.readyState == 4 || settings.readyState == 0) {
  4.  
  5. var car = escape(document.getElementById('car').value);
  6.  
  7. /* PROBLEM - Radio Button Processor */
  8. var proc17 = document.getElementById("search17");
  9. for (var i = 0; i < proc17.length; i++)
  10. {
  11. if (proc17[i].checked){
  12. search17 = proc17[i].value;
  13. break;
  14. }
  15. }
  16.  
  17.  
  18. settings.open("GET", 'abc.php?proc17=' + proc17 + '&car=' +car, true);
  19. settings.onreadystatechange = handleSettings; settings.send(null);}}
  20. function handleSettings() { if (settings.readyState == 4) {
  21.  
  22. }
  23. }
  24. </script>
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 431
Reputation: Atli is on a distinguished road 
Solved Threads: 56
Atli's Avatar
Atli Atli is offline Offline
Posting Pro in Training

Re: Problem with Radio Button error "[object HTMLInputElement]"

 
0
  #2
Sep 5th, 2008
Aren't you using the wrong variable in your AJAX URL string?

You assign the "search17" element to the "proc17" variable and then use that in your URL.
Shouldn't the "search17" variable be in the URL?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 36
Reputation: lonestar23 is an unknown quantity at this point 
Solved Threads: 0
lonestar23 lonestar23 is offline Offline
Light Poster

Re: Problem with Radio Button error "[object HTMLInputElement]"

 
1
  #3
Sep 10th, 2008
The code that ended up working for me is below. I have included only the ajax javascript Thanks to all for your help!

  1.  
  2. var settings = getXmlHttpRequestObject(); function savePreview() {
  3. if (settings.readyState == 4 || settings.readyState == 0) {
  4.  
  5. var car = escape(document.getElementById('car').value);
  6.  
  7. for (index=0; index < document.gMoney.searchMe.length; index++) {
  8. if (document.gMoney.searchMe[index].checked) {
  9. var radioValue = document.gMoney.searchMe[index].value;
  10. break;
  11. }
  12. }
  13.  
  14.  
  15. settings.open("GET", 'abc.php?searchMe=' + radioValue + '&car=' +car, true);
  16. settings.onreadystatechange = handleSettings; settings.send(null);}}
  17. function handleSettings() { if (settings.readyState == 4) {
  18. }
  19. }
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC