shanparker
07-13-2007, 12:13 AM
I've looked this up online and since I'm not great with neither AJAX or JS I'm a little bit at a loss. I read that I needed to use ID tags, but that still didn't get me far. Can anyone take a look at this and help me figure out why the radio buttons don't send to the php script?
Thanks in advance!!
<?
$query = "SELECT * FROM spicegirls_tour ORDER BY 'id' ASC";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){ // loop through the result of the page.
?>
<tr>
<td><input type="radio" name="local" id="local[<? echo $row[id]; ?>]" value="<? echo $row[id]; ?>"></td>
<td><? echo $row[local]; ?></td>
</tr>
<?
}
?>
<script language="Javascript">
// You don't need to change anything in this function:
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}
// The following function obtains two variables from your form (email and message)
// and builds a string that gets sent to your PHP script. Change this function to
// obtain whatever fields you want from your form.
function getquerystring() {
var form = document.forms['form1'];
var local = form.local.value;
var username = form.username.value;
qstr = 'local=' + escape(local) + '&username=' + escape(username);
return qstr;
}
function updatepage(str){
document.getElementById("result").innerHTML = str;
}
</script>
Thanks in advance!!
<?
$query = "SELECT * FROM spicegirls_tour ORDER BY 'id' ASC";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){ // loop through the result of the page.
?>
<tr>
<td><input type="radio" name="local" id="local[<? echo $row[id]; ?>]" value="<? echo $row[id]; ?>"></td>
<td><? echo $row[local]; ?></td>
</tr>
<?
}
?>
<script language="Javascript">
// You don't need to change anything in this function:
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}
// The following function obtains two variables from your form (email and message)
// and builds a string that gets sent to your PHP script. Change this function to
// obtain whatever fields you want from your form.
function getquerystring() {
var form = document.forms['form1'];
var local = form.local.value;
var username = form.username.value;
qstr = 'local=' + escape(local) + '&username=' + escape(username);
return qstr;
}
function updatepage(str){
document.getElementById("result").innerHTML = str;
}
</script>