| | |
multiple radiobutton values ajax problem
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi
I'm having problem with some radiobuttons. On this page I have two groups of radiobuttons and four textboxes. The code works fine with the first set of radiobuttons, but when I try to add code for the second group it doesn't work.... Here's the code.
And here's the php file.
I would very much appricate some help, since I have not found a solution for this despite hours of googleing...
I'm having problem with some radiobuttons. On this page I have two groups of radiobuttons and four textboxes. The code works fine with the first set of radiobuttons, but when I try to add code for the second group it doesn't work.... Here's the code.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Test</title> <script type="text/javascript" language="javascript"> var http_request = false; function makeRequest(url, parameters) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('GET', url + parameters, true); http_request.send(null); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { //alert(http_request.responseText); result = http_request.responseText; document.getElementById('myspan').innerHTML = result; } else { alert('There was a problem with the request.'); } } } function get(obj) { var getstr = "?"; for (i=0; i<obj.childNodes.length; i++) { if (obj.childNodes[i].tagName == "INPUT") { if (obj.childNodes[i].name == "Name") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } if (obj.childNodes[i].name == "Email") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } if (obj.childNodes[i].name == "Script") { if (obj.childNodes[i].checked) { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } if (obj.childNodes[i].name == "Annat") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } if (obj.childNodes[i].name == "Annat2") { getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&"; } } } } makeRequest('get.php', getstr); } </script> </head> <body> <h1>Ange namn och epost:</h1> <br /> <form action="javascript:get(document.getElementById('myform'));" name="myform" id="myform"> Namn: <input type="text" name="Name" value=""><br /> Epost: <input type="text" name="Email" value=""><br /> <h1>Rösta på följande:</h1> <h2>Fråga 1: Vilket script språk gillar du bäst?</h2> <input type="radio" name="Script" value="PHP" checked> PHP<br /> <input type="radio" name="Script" value="ASP.NET"> ASP.NET<br /> <input type="radio" name="Script" value="JSP"> JSP<br /> <input type="radio" name="Script" value="AJAX"> AJAX<br /> Annat: <br /> <input id="Annat" type="text" value="" /> <br /> <br /> <input type="radio" name="os" value="MS Windows" checked> MS Windows<br /> <input type="radio" name="os" value="LINUX" > LINUX<br /> <input id="Annat2" type="text" value="" /> <br /> <input type="button" name="button" value="Rösta!" onclick="javascript:get(this.parentNode);"> </form> <br><br> Dina svar:<br> <span name="myspan" id="myspan"></span> </body> </html>
And here's the php file.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<?php foreach ($_GET as $key => $value) { echo $key . ' : ' . $value . '<br />'; } ?>
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: drop down menu call javascript function
- Next Thread: Run function upon pressing enter
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser captchaformproblem checkbox child close codes css debugger decimal dependent disablefirebug dom download editor element engine enter error events explorer ext file firefox form forms frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math media menu microsoft mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php player position problem programming prototype redirect regex runtime safari scale scriptlets search security select size software sql textarea unicode w3c window windowofwords windowsxp wysiwyg \n





