[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.3

Hidden fields and onchange event in forms and dependent dropdown menus

Asked by BelindaFerraz in PHP and Databases, Adobe Dreamweaver, JavaScript

Tags: PHP, Firefox, safari

I am working with Dreamweaver CS3, php and have a mysql database. I have a search form on my website that has 5 dropdown menus for user to choose from. On submit - the page will show a set of results and the form will retain the users input incase they want to do a further search.

Dropdown 1 - simple choice between 'buy' or 'let'. Depending on what user chooses it will effect dropdown 3 and 4

Dropdown 3 - minprice. For a 'buy' selection the price will be £100,000, £200,000 etc and for 'let' it will be £50 per week, £100 per week etc.

Dropdown 4 - maxprice. For a 'buy' selection the price will be £200,000, £300,000 etc and for 'let' it will be £100 per week, £150 per week etc.

At the moment I have an onchange event happening on the dropdown 1 which is working well except for when it come to retaining user input from page to page. If the user chooses 'let' it will continue the search thru to the reultts.php but the search form dropdown 3 and 4 revert back to a 'buy' selection instead of remaining on a 'let' selection.

I thought of using hidden fields and onchange event but not to sure how to put that all together. I have had a look at similar questions on this and other sites but as I have not used javascript and am new to php it is all very confusing for me.

Can anyone help me make this form work properly.

Here attached is the code for my form and javascript.

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
// Javascript for onchange event
 
<Script>
function drop() {
var l;
l = document.form1.varminprice
 
// Here Define the Option's for the Second Drop down menu
 
var Let = new Array(" Select one option ","£50 per week","£100 per week","£150 per week","£200 per week","£250 per week","£300 per week","£350 per week","£400 per week","£450 per week")
var Buy = new Array(" Select one option ","£100,000","£200,000","£300,000","£400,000","£500,000","£750,000","£1,000,000")
 
// here Test it the Let From the First Drop Down menu is Selected
 
if(document.form1.varsaleorlet.options[document.form1.varsaleorlet.options.selectedIndex].text=="Let"){
l.length=0
for(i=0; i<Let.length; i++) {
document.form1.varminprice.options[i] = new Option(Let[i])
document.form1.varmaxprice.options[i] = new Option(Let[i])
}
return;
}
 
// End First Drop down menu here
 
else if(document.form1.varsaleorlet.options[document.form1.varsaleorlet.options.selectedIndex].text=="Buy"){
l.length=0
 
for(i=0; i<Buy.length; i++) {
document.form1.varminprice.options[i] = new Option(Buy[i])
document.form1.varmaxprice.options[i] = new Option(Buy[i])
 
}
 
return;
}
 
else {
l.length=0;
}
 
}
// End Function here for the Second Drop Down
 
</Script>
 
// my search form
 
<td valign="top"><form accept-charset="utf-8" id="form1" name="form1" method="get" action="results.php">
<label for="varsaleorlet">Buy or Let:</label>
<select name="varsaleorlet" class="value" id="varsaleorlet" onchange="drop()">
<option value="">&ndash; Select one option &ndash;</option>
<option value="buy"<?php echo ('buy' == $_SESSION['varsaleorlet'] ? ' selected="selected"' : '' ) ?>>Buy</option>
<option value="let"<?php echo ('let' == $_SESSION['varsaleorlet'] ? ' selected="selected"' : '' ) ?>>Let</option>
</select>
<br/>
<br/>
<label for="vararea">Area:</label>
<select name="vararea" class="value" id="vararea">
<option selected="selected">&ndash; Select one option &ndash;</option>
<option value="SW11"<?php echo ('SW11' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW11</option>
<option value="SW12"<?php echo ('SW12' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW12</option>
<option value="SW16"<?php echo ('SW16' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW16</option>
<option value="SW17"<?php echo ('SW16' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW17</option>
<option value="SW18"<?php echo ('SW18' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW18</option>
<option value="SW4"<?php echo ('SW4' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW4</option>
<option value="SW6"<?php echo ('SW6' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW6</option>
<option value="SW8"<?php echo ('SW8' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW8</option>
<option value="SW9"<?php echo ('SW9' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>SW9</option>
<option value="all"<?php echo ('all' == $_SESSION['vararea'] ? ' selected="selected"' : '' ) ?>>All Areas</option>
</select>
<br />
<br />
<label for="varminprice">Minimum Price</label>
<select name="varminprice" size="1" class="value" onchange="drop2(this)">
<option>&ndash; Select one option &ndash;</option>
<option value="£100,000"<?php echo ('£100,000' == $_SESSION['varminprice'] ? ' selected="selected"' : '' ) ?>>£100,000</option>
<option value="£200,000"<?php echo ('£200,000' == $_SESSION['varminprice'] ? ' selected="selected"' : '' ) ?>>£200,000</option>
<option value="£300,000"<?php echo ('£300,000' == $_SESSION['varminprice'] ? ' selected="selected"' : '' ) ?>>£300,000</option>
<option value="£400,000"<?php echo ('£400,000' == $_SESSION['varminprice'] ? ' selected="selected"' : '' ) ?>>£400,000</option>
<option value="£500,000"<?php echo ('£500,000' == $_SESSION['varminprice'] ? ' selected="selected"' : '' ) ?>>£500,000</option>
<option value="£750,000"<?php echo ('£750,000' == $_SESSION['varminprice'] ? ' selected="selected"' : '' ) ?>>£750,000</option>
<option value="£1,000,000"<?php echo ('£1,000,000' == $_SESSION['varminprice'] ? ' selected="selected"' : '' ) ?>>£1,000,000</option>
</select>
<br />
<br />
<label for="varmaxprice">Maximum Price</label>
<select name="varmaxprice" class="value" id="varmaxprice">
<option selected="selected"> Select one option </option>
<option value="£200,000"<?php echo ('£200,000' == $_SESSION['varmaxprice'] ? ' selected="selected"' : '' ) ?>>£200,000</option>
<option value="£300,000"<?php echo ('£300,000' == $_SESSION['varmaxprice'] ? ' selected="selected"' : '' ) ?>>£300,000</option>
<option value="£400,000"<?php echo ('£400,000' == $_SESSION['varmaxprice'] ? ' selected="selected"' : '' ) ?>>£400,000</option>
<option value="£500,000"<?php echo ('£500,000' == $_SESSION['varmaxprice'] ? ' selected="selected"' : '' ) ?>>£500,000</option>
<option value="£750,000"<?php echo ('£750,000' == $_SESSION['varmaxprice'] ? ' selected="selected"' : '' ) ?>>£750,000</option>
<option value="£1,000,000"<?php echo ('£1,000,000' == $_SESSION['varmaxprice'] ? ' selected="selected"' : '' ) ?>>£1,000,000</option>
<option value="£2,000,000"<?php echo ('£2,000,000' == $_SESSION['varmaxprice'] ? ' selected="selected"' : '' ) ?>>£2,000,000</option>
</select>
<br />
<br />
<label for="varbedrooms">No. of Bedrooms</label>
<select name="varbedrooms" class="value" id="varbedrooms">
<option> Select one option </option>
<option value="Studio"<?php echo ('Studio' == $_SESSION['varbedrooms'] ? ' selected="selected"' : '' ) ?>>Studio</option>
<option value="1"<?php echo ('1' == $_SESSION['varbedrooms'] ? ' selected="selected"' : '' ) ?>>1</option>
<option value="2"<?php echo ('2' == $_SESSION['varbedrooms'] ? ' selected="selected"' : '' ) ?>>2</option>
<option value="3"<?php echo ('3' == $_SESSION['varbedrooms'] ? ' selected="selected"' : '' ) ?>>3</option>
<option value="4"<?php echo ('4' == $_SESSION['varbedrooms'] ? ' selected="selected"' : '' ) ?>>4</option>
<option value="5"<?php echo ('5' == $_SESSION['varbedrooms'] ? ' selected="selected"' : '' ) ?>>5</option>
<option value="6+"<?php echo ('+6' == $_SESSION['varbedrooms'] ? ' selected="selected"' : '' ) ?>>6+</option>
</select>
<br />
<br />
<label for="search"></label>
<input name="search" type="submit" class="value" id="search" value="SEARCH" />
<input name="reset" type="reset" class="value" id="reset" value="NEW SEARCH" />
</form></td>
 
Related Solutions
Keywords: Hidden fields and onchange event in fo…
 
Loading Advertisement...
 
[+][-]04/19/08 11:58 AM, ID: 21393520Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/19/08 12:21 PM, ID: 21393580Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/21/08 03:53 PM, ID: 21406836Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/21/08 07:23 PM, ID: 21407763Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/22/08 01:41 AM, ID: 21409053Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/22/08 04:39 AM, ID: 21409869Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/22/08 10:13 AM, ID: 21413269Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/22/08 10:47 AM, ID: 21413624Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/23/08 07:35 PM, ID: 21427379Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/24/08 01:38 AM, ID: 21428675Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04/25/08 12:01 PM, ID: 21442370Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/21/08 03:01 AM, ID: 21613408Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/21/08 05:05 AM, ID: 21614102Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/22/08 03:14 AM, ID: 21622409Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/23/08 01:17 PM, ID: 21635489Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/27/08 07:42 AM, ID: 21652245Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/28/08 01:25 PM, ID: 21664045Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05/29/08 07:43 AM, ID: 21669584Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/04/08 03:58 PM, ID: 21714956Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/04/08 03:59 PM, ID: 21714963Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/12/08 05:44 AM, ID: 21768751Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/12/08 01:40 PM, ID: 21773500Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/13/08 03:09 PM, ID: 21783140Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/13/08 10:22 PM, ID: 21784196Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/16/08 07:56 AM, ID: 21794188Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/16/08 09:00 AM, ID: 21794872Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/16/08 02:33 PM, ID: 21797720Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/16/08 06:15 PM, ID: 21798860Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: PHP and Databases, Adobe Dreamweaver, JavaScript
Tags: PHP, Firefox, safari
Sign Up Now!
Solution Provided By: routinet
Participating Experts: 2
Solution Grade: A
 
[+][-]06/18/08 10:10 PM, ID: 21819404Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 / EE_QW_2_20070628