CoolAsCarlito
10-22-2008, 01:15 AM
I changed some things and am doing this for someone else as well for his site. I have the shownames showing correctly in the dropdown however it's not putting the integer into the readonly input field. Anyone know why?
Here's my form:
<?php
print '<form action="setupshow.php" method="post" name="myForm">';
print '<tr><td>Show Name:</td><td><select name="showname" id=\"names\" onChange="ajaxGet();"><option value="">Select a Name</option>';
$query = 'SELECT showname FROM shownames ORDER BY showname';
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
print "<option value=\"{$row['showname']}\">{$row['showname']}</option>\r";
}
print '</select></td></tr>';
print '<tr><td>Show Label:</td><td><input name="showlabel" id="label" type="text" readonly="true" size="5"></td></tr>';
print '<tr><th colspan=2><input name="submit" type="submit" value="Submit"><input name="sumbitted" type="hidden" value="TRUE"></th></tr></table></form>';
?>
Here's my javascript code:
<script type="text/javascript">
function ajaxGet()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById('shownam').innerHTML = xmlHttp.responseText;
ajaxGetL();
}
}
//alert("Selected: " + document.getElementById("ajax1").value);
xmlHttp.open("GET","showAjax.php?type=" + document.getElementById("ajax1").value + "&rand=" + Math.random(),true);
xmlHttp.send(null);
}
function ajaxGetL()
{
//alert("CALLED");
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById('label').value = xmlHttp.responseText;
}
}
//alert("Selected: " + document.getElementById("ajax1").value);
xmlHttp.open("GET","showAjax.php?label=" + document.getElementById("names").value + "&rand=" + Math.random(),true);
xmlHttp.send(null);
}
</script>
Here's my ajax page:
<?php
require('database.php');
if(isset($_GET['label']))
{
$label = mysql_real_escape_string($_GET['label'],$link);
$res = mysql_query("SELECT `showlabel` FROM `shownames` WHERE `showname` = '".$label."' ORDER BY `showlabel` DESC LIMIT 1;") or die("ERROR 1");
$list = mysql_fetch_assoc($res);
echo $list['showlabel']+1;
}
?>
Here's my form:
<?php
print '<form action="setupshow.php" method="post" name="myForm">';
print '<tr><td>Show Name:</td><td><select name="showname" id=\"names\" onChange="ajaxGet();"><option value="">Select a Name</option>';
$query = 'SELECT showname FROM shownames ORDER BY showname';
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
print "<option value=\"{$row['showname']}\">{$row['showname']}</option>\r";
}
print '</select></td></tr>';
print '<tr><td>Show Label:</td><td><input name="showlabel" id="label" type="text" readonly="true" size="5"></td></tr>';
print '<tr><th colspan=2><input name="submit" type="submit" value="Submit"><input name="sumbitted" type="hidden" value="TRUE"></th></tr></table></form>';
?>
Here's my javascript code:
<script type="text/javascript">
function ajaxGet()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById('shownam').innerHTML = xmlHttp.responseText;
ajaxGetL();
}
}
//alert("Selected: " + document.getElementById("ajax1").value);
xmlHttp.open("GET","showAjax.php?type=" + document.getElementById("ajax1").value + "&rand=" + Math.random(),true);
xmlHttp.send(null);
}
function ajaxGetL()
{
//alert("CALLED");
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.getElementById('label').value = xmlHttp.responseText;
}
}
//alert("Selected: " + document.getElementById("ajax1").value);
xmlHttp.open("GET","showAjax.php?label=" + document.getElementById("names").value + "&rand=" + Math.random(),true);
xmlHttp.send(null);
}
</script>
Here's my ajax page:
<?php
require('database.php');
if(isset($_GET['label']))
{
$label = mysql_real_escape_string($_GET['label'],$link);
$res = mysql_query("SELECT `showlabel` FROM `shownames` WHERE `showname` = '".$label."' ORDER BY `showlabel` DESC LIMIT 1;") or die("ERROR 1");
$list = mysql_fetch_assoc($res);
echo $list['showlabel']+1;
}
?>