So why don't you do this:
JavaScript:
$(function(){
$("div.opt").hide();
$("select").change(function(){
$("div.opt").hide();
$("div."+$(this).val()).show();
});
});
Document:
<select name="user">
<option value="t1">Administrator</option>
<option value="t2">Manager</option>
<option value="t3">Executive</option>
</select>
<div class="opt t1 t2 t3">
<label for="text1">Field Number One</label>
<input type="text" name="text1"></input>
</div>
<div class="opt t3">
<label for="text1">Field Number Two</label>
<input type="text" name="text1"></input>
</div>
<div class="opt t2 t3">
<label for="text1">Field Number Three</label>
<input type="text" name="text1"></input>
</div>
So basically, the option values are the class names of the divisions you
want to show when someone selects a new user type. $().change fires whenever
a new user type is selected.
- jake
On 3/8/07, Agrawal, Ritesh <[EMAIL PROTECTED]> wrote:
Hi,
I need some idea on how to do this.
I have a big user survey form. It has around 25 fields. However, depending
on the type of user such as administrator, member, etc...many fields are
not
required. In my survey form, a user will select "user type" from a select
box.
My problem: I don't want to scare off users from filling the survey form.
Thus, I want to display only the relevant fields depending on the user
type
they have selected. What I would like to do is to add some script to
change
method of select box and hide/show fields dependening on the selection.
However, I am not sure what's the best way to handle list of box to show
and
hide...I am trying to avoid a long list of if else ..
any idea is welcome
Regards,
Ritesh
--
View this message in context:
http://www.nabble.com/need-some-idea-tf3371424.html#a9381497
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/