Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic form ?

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi all,

what i'd like to do is :
i do have two select box. one called condition and one called operation.

an example :
<select name=&quot;condition&quot;>
<option value=&quot;&quot; selected>Date</option>
<option value=&quot;&quot;>String</option>
<option value=&quot;&quot;>Code</option>
</select>
<select name=&quot;operation&quot;>
<option value=&quot;&quot; selected>equals to</option>
<option value=&quot;&quot;>not equals to</option>
<option value=&quot;&quot;>begin with</option>
<option value=&quot;&quot;><</option>
<option value=&quot;&quot;>></option>
<option value=&quot;&quot;>contains</option>
</select>


what i want is that when i select the condition, the operation select box will only have certain options (i mean for example i do have 3 conditions option : date, string, code. with date i should only have &quot;<&quot;, &quot;>&quot; and &quot;equals to&quot; operartion, but for string i could have &quot;containing&quot; or &quot;begining&quot;. and for code i should only have &quot;equals to&quot;)

i fact i want that my second select box dinamicaly when someone choose an option of the first one.

is there a way to do that in JS ? what kind of properties and action should i deal with ?




Best regards X-),
Elise
 
hi tyris,
the following is a similar code check it out.
hope this helps.
cheers!
-----------------------------------------------------------
<html>
<title>Your Web Page Title Goes Here</title>

<body bgcolor=white>
<script language=&quot;JavaScript&quot;>
<!--
if (document.images) {
activities = new Object();
activities.spring = new Array(&quot;Cleaning&quot;,&quot;Mowing&quot;,&quot;Planting&quot;);
activities.summer = new Array(&quot;Swimming&quot;,&quot;Baseball&quot;,&quot;Camping&quot;);
activities.fall = new Array(&quot;Raking&quot;,&quot;Football&quot;,&quot;School&quot;);
activities.winter = new Array(&quot;Ice skating&quot;,&quot;Sledding&quot;,&quot;Skiing&quot;);
clothes = new Object();
clothes.spring = new Array(&quot;Rain jacket&quot;,&quot;T-shirts&quot;,&quot;Tennis shoes&quot;);
clothes.summer = new Array(&quot;Shorts&quot;,&quot;Tank-tops&quot;,&quot;Sandals&quot;);
clothes.fall = new Array(&quot;Light jacket&quot;,&quot;Jeans&quot;,&quot;Sweater&quot;);
clothes.winter = new Array(&quot;Scarf&quot;,&quot;Gloves&quot;,&quot;Parka&quot;);
}
function updateMenus(season) {
if (document.images) {
sel = season.selectedIndex;
if (sel == 1) {
act = activities.spring;
cloth = clothes.spring;
} else if (sel == 2) {
act = activities.summer;
cloth = clothes.summer;
} else if (sel == 3) {
act = activities.fall;
cloth = clothes.fall;
} else if (sel == 4) {
act = activities.winter;
cloth = clothes.winter;
} else {
act = new Array();
cloth = new Array();
}
season.form.activities.length = act.length;
for(i=0;i<act.length;i++)
season.form.activities.options.text = act;
season.form.clothes.length = cloth.length;
for(i=0;i<cloth.length;i++)
season.form.clothes.options.text = cloth;
} else {
alert(&quot;Your browser does not allow this script to modify the &quot;
+&quot;activities and clothes selection lists. Get a newer browser.&quot;);
}
}
// -->
</script>

<form>
<br>
<br>


<select name=&quot;season&quot; size=1 onChange=&quot;updateMenus(this)&quot;>
<option>Choose Season
<option>Spring
<option>Summer
<option>Fall
<option>Winter
</select><br><br>

Activities:<br>
<select name=&quot;activities&quot; size=1>
<option>                 
</select><br><br>

Clothes:<br>
<select name=&quot;clothes&quot; size=1>
<option>                 
</select><br>
</form>
</body>
</html>
----------------------------------------------------
 
thanks for your answer.

i cutted and pasted the code you gave me but nothing works and sel and act variables are not defined. what's wrong ? Best regards X-),
Elise
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top