943,522 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 4070
  • PHP RSS
Sep 5th, 2008
0

Problem with Radio Button error "[object HTMLInputElement]"

Expand Post »
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

PHP Syntax (Toggle Plain Text)
  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>
Reputation Points: 20
Solved Threads: 0
Light Poster
lonestar23 is offline Offline
43 posts
since Mar 2008
Sep 5th, 2008
0

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

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?
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007
Sep 10th, 2008
1

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

The code that ended up working for me is below. I have included only the ajax javascript Thanks to all for your help!

PHP Syntax (Toggle Plain Text)
  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. }
Reputation Points: 20
Solved Threads: 0
Light Poster
lonestar23 is offline Offline
43 posts
since Mar 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Errors after installing WAMP Server 2
Next Thread in PHP Forum Timeline: convert PHP to javascript?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC