alex57
11-16-2006, 05:33 PM
Hello,
bit of an odd question, as this may be more javascript im not sure. I have a simple drop down box containing several values. Ideally i would like to select a value without using a button (with an onchange event) and use that value in an sql query. I have had a go myself below. Any help would be appreciated as I end up having to convert a javascript variable to php which cannot be done easily. Is there anyway to do this not using javascript and purely php??
thanks
<html>
<head>
<script language=JavaScript>
var TestVar
function show(form)
{
TestVar = form.clubs.value;
alert(TestVar);
var fred="<?php=$fred?>";
}
</script>
</head>
<body>
<form name"myform">
<select name=clubs onChange="show(this.form)">
<option value=select selected="selected">- Select -</option>
<option value=break>---------------------</option>
<option value=<?php $variable = goalkeepers?> >Goal Keepers</option>
<option value=<?php $variable = defenders?> > Defenders</option>"
<option value=midfielders>Midfielders</option>
<option value=strikers>Strikers</option>
<option value=break2>---------------------</option>
</select>
</form>
</script>
<?php
echo $variable;
?>
</body>
</html>
bit of an odd question, as this may be more javascript im not sure. I have a simple drop down box containing several values. Ideally i would like to select a value without using a button (with an onchange event) and use that value in an sql query. I have had a go myself below. Any help would be appreciated as I end up having to convert a javascript variable to php which cannot be done easily. Is there anyway to do this not using javascript and purely php??
thanks
<html>
<head>
<script language=JavaScript>
var TestVar
function show(form)
{
TestVar = form.clubs.value;
alert(TestVar);
var fred="<?php=$fred?>";
}
</script>
</head>
<body>
<form name"myform">
<select name=clubs onChange="show(this.form)">
<option value=select selected="selected">- Select -</option>
<option value=break>---------------------</option>
<option value=<?php $variable = goalkeepers?> >Goal Keepers</option>
<option value=<?php $variable = defenders?> > Defenders</option>"
<option value=midfielders>Midfielders</option>
<option value=strikers>Strikers</option>
<option value=break2>---------------------</option>
</select>
</form>
</script>
<?php
echo $variable;
?>
</body>
</html>