street9009 Posted January 29, 2008 Share Posted January 29, 2008 Hello all, I followed a simple tutorial to get this working and it's working great, all except one problem. Let me explain. I have a simple form that's a survey. Some questions consist of a Yes or No response. Others can have any number of 22 responses checked. I have each "group" of radio buttons or checkboxes named the same (q1, q2, etc.) My insert function(s) look something like this: /* -------------------------- */ /* INSERT */ /* -------------------------- */ /* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */ var nocache = 0; function insert() { // Optional: Show a waiting message in the layer with ID login_response document.getElementById('insert_response').innerHTML = "Please wait while your record is inserted into the database..." // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding. var surveyID = encodeURI(document.getElementById('surveyID').value); var accountID= encodeURI(document.getElementById('accountnum').value); var q1 = encodeURI(document.getElementById('q1').value); var q2 = encodeURI(document.getElementById('q2').value); var q3 = encodeURI(document.getElementById('q3').value); var q4 = encodeURI(document.getElementById('q4').value); var q5 = encodeURI(document.getElementById('q5').value); var q6 = encodeURI(document.getElementById('q6').value); var q7 = encodeURI(document.getElementById('q7').value); var q8 = encodeURI(document.getElementById('q8').value); var q8a = encodeURI(document.getElementById('q8a').value); // Set te random number to add to URL request nocache = Math.random(); // Pass the login variables like URL variable http.open('get', 'insert.php?surveyID='+surveyID+'&accountID=' +accountID+'&q1=' +q1+'&q2=' +q2+'&q3=' +q3+'&q4=' +q4+'&q5=' +q5+'&q6=' +q6+'&q7=' +q7+'&q8=' +q8+'&q8a=' +q8a+'&nocache = '+nocache); http.onreadystatechange = insertReply; http.send(null); } function insertReply() { if(http.readyState == 4) { var response = http.responseText; // else if login is ok show a message: "Site added+ site URL". document.getElementById('insert_response').innerHTML = response; } } The problem with this is it always picks up the first input named q1, q2, etc. no matter which are selected. How should I fix this? Link to comment https://forums.phpfreaks.com/topic/88392-solved-inserting-radiocheckbox-values-to-db/ Share on other sites More sharing options...
street9009 Posted January 29, 2008 Author Share Posted January 29, 2008 Nevermind, I found a script at the following address that helped. http://www.breakingpar.com/bkp/home.nsf/0/CA99375CC06FB52687256AFB0013E5E9 Link to comment https://forums.phpfreaks.com/topic/88392-solved-inserting-radiocheckbox-values-to-db/#findComment-452667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.