Web Hosting Talk







View Full Version : Loading.....


kooshin
02-26-2005, 10:31 AM
Hello guys. I have a question. I have a form which which has some text fields and one drop down menu which has two options in it like 1 and 2. I want a new page to be loaded whenever one of those two options is selected, like you select 1 then a new page is loaded. Also what the person filled in the form should be passed to the new form or page. How can I do that in php since it is what am using ? Thanks,

itspot
02-28-2005, 03:30 AM
You can redirect the page to the corresponding pages depending on the chosen value and pass the parameters in the query string. The thing could be done with JavaScript.

Something like
<script>

function PassParameters(index){

var url = "";
if(index == 1) { url = "someUrl?var1" + document.form.field.value;
document.location.href = url;
}
else if(index == 2) {
....
}
}
</script>

<select onChange="PassParameters(this.selectedIndex)">
<option value=1">
<option value=2">
</select>


The example is clumsy, but you can get the idea.

X-TechMedia
02-28-2005, 01:03 PM
Or you could put everything in a form, then post it back to yourself.
Somthing like...

<script>
function Change(value) {
if (value == 1) {
document.getElementById('myform').action = 'thispage.php';
} elseif (value == 2) {
document.getElementById('myform').action = 'thatpage.php';
}...

document.getElementById('myform').submit();
}
</script>

<form method="post" name="myform">
<input type="text" name="blah">
...
<select onChange="Change(this.value)">
<option value=1">1</option>
<option value=2">2</option>
</select>
</form>

kooshin
03-07-2005, 04:05 PM
Ok guys thanks I will try that but can't it be done with PHP?