Hi All,
I'm new to this forum.. I need a help. I want to make a search form which contains [b]make, model and year of make[/b] as search condition. All these information should be taken from the database. After selecting the [b]make[/b] the [b]model[/b] selection menu should take the value which is coming under the same [b]make[/b]. Is it possible to reload the same page and take the value from the database. or it is possible to add a select table values where the select query contains a criteria which is taken from the same just before that.
Thanks in advance
Shemim
Page Reload
Moderator: General Moderators
-
shemimkamal
- Forum Newbie
- Posts: 1
- Joined: Thu Aug 07, 2003 12:35 am
- Location: Cochin
- Contact:
This is just how I would solve the problem. It would require your php code to put out some java with it. I would get the all the information from the data base and load the Make selection box. I would at the same time tie the Make selection to a java script that loads the appropriate values in the Model Selection box. Here's an example we use for our hosting packages...
var MB25Array = new Array("('Select Payment','',true,true)",
"('Yearly: $143.40-[11.95 a month] ')",
"('Monthly: $12.95')");
var MB50Array = new Array("('Select Payment','',true,true)",
"('Yearly: $155.40 [12.95 a month] ')",
"('Monthly: $14.95')");
var MB150Array = new Array("('Select Payment','',true,true)",
"('Yearly: $191.40 [22.95 a month] ')",
"('Monthly: $24.95')");
var MB300Array = new Array("('Select Payment','',true,true)",
"('Yearly: $551.40 [45.95 a month] ')",
"('Monthly: $49.95')");
var MB400Array = new Array("('Select Payment','',true,true)",
"('Yearly: $659.45 [54.95 a month] ')",
"('Monthly: $59.95')");
var MB500Array = new Array("('Select Payment','',true,true)",
"('Yearly: $767.40 [63.95 a month] ')",
"('Monthly: $69.95')");
function populatePricing(inForm,selected)
{
var selectedArray = eval(selected + "Array");
while (selectedArray.length < inForm.pricing.options.length)
{
inForm.pricing.options[(inForm.pricing.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++)
{
eval("inForm.pricing.options=" + "new Option" + selectedArray);
}
if (inForm.package.options[0].value == '')
{
inForm.package.options[0]= null;
if ( navigator.appName == 'Netscape')
{
if (parseInt(navigator.appVersion) < 4)
{
window.history.go(0);
}else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16')
{
window.history.go(0);
}
}
}
}
}
And the selection box which would contain your Make that calls the
above code...
<select name="ta_package" onchange="populatePricing(document.hosting,document.hosting.package.options[document.hosting.package.selectedIndex].value)">
<option value="">Select Package</option>
<option value="MB25">25 MB - 1 GB Transfer</option>
<option value="MB50">50 MB - 2 GB Transfer</option>
<option value="MB150">150 MB - 4 GB Transfer</option>
<option value="MB300">300 MB - 8 GB Transfer</option>
<option value="MB400">400 MB - 10 GB Transfer</option>
<option value="MB500">500MB - 10 GB Transfer</option>
</select> <select name="pricing">
var MB25Array = new Array("('Select Payment','',true,true)",
"('Yearly: $143.40-[11.95 a month] ')",
"('Monthly: $12.95')");
var MB50Array = new Array("('Select Payment','',true,true)",
"('Yearly: $155.40 [12.95 a month] ')",
"('Monthly: $14.95')");
var MB150Array = new Array("('Select Payment','',true,true)",
"('Yearly: $191.40 [22.95 a month] ')",
"('Monthly: $24.95')");
var MB300Array = new Array("('Select Payment','',true,true)",
"('Yearly: $551.40 [45.95 a month] ')",
"('Monthly: $49.95')");
var MB400Array = new Array("('Select Payment','',true,true)",
"('Yearly: $659.45 [54.95 a month] ')",
"('Monthly: $59.95')");
var MB500Array = new Array("('Select Payment','',true,true)",
"('Yearly: $767.40 [63.95 a month] ')",
"('Monthly: $69.95')");
function populatePricing(inForm,selected)
{
var selectedArray = eval(selected + "Array");
while (selectedArray.length < inForm.pricing.options.length)
{
inForm.pricing.options[(inForm.pricing.options.length - 1)] = null;
}
for (var i=0; i < selectedArray.length; i++)
{
eval("inForm.pricing.options=" + "new Option" + selectedArray);
}
if (inForm.package.options[0].value == '')
{
inForm.package.options[0]= null;
if ( navigator.appName == 'Netscape')
{
if (parseInt(navigator.appVersion) < 4)
{
window.history.go(0);
}else {
if (navigator.platform == 'Win32' || navigator.platform == 'Win16')
{
window.history.go(0);
}
}
}
}
}
And the selection box which would contain your Make that calls the
above code...
<select name="ta_package" onchange="populatePricing(document.hosting,document.hosting.package.options[document.hosting.package.selectedIndex].value)">
<option value="">Select Package</option>
<option value="MB25">25 MB - 1 GB Transfer</option>
<option value="MB50">50 MB - 2 GB Transfer</option>
<option value="MB150">150 MB - 4 GB Transfer</option>
<option value="MB300">300 MB - 8 GB Transfer</option>
<option value="MB400">400 MB - 10 GB Transfer</option>
<option value="MB500">500MB - 10 GB Transfer</option>
</select> <select name="pricing">
-
tylerdurden
- Forum Commoner
- Posts: 66
- Joined: Mon Jul 28, 2003 11:52 am
- Location: Austria
Two things about the above examle:
of course you have put in there. Also you'll have to replace every inForm.package with inForm.ta_package
You may also want to have a look at this: viewtopic.php?t=11227
of course you have put
Code: Select all
<form name="hosting">You may also want to have a look at this: viewtopic.php?t=11227