Jump to content

select drop down menu, if a certain item is selected, so div of html


bradkenyon

Recommended Posts

I have a drop down box that I want to display certain information if that item is selected within the select drop down box.

 

So if that item is selected, then it will automatically display another part of the form the user will need to fill out.

 

i want to do this, so it will shorten the form up for the user, basically only showing the fields they need to fill out based on what item they select in the drop down box.

 

How do I accomplish this using jQuery?

Link to comment
Share on other sites

$(document).ready(function() {
$('select').change(function() {
	var thisValue = $(this).val();
	switch (thisValue) {
		case "1":
			$("div.event_fields").fadeIn("slow");
		break;
		case "2":
			$("div.event_fields").fadeIn("slow");
		break;
		case "3":
			$("div.event_fields").fadeIn("slow");
		break;
		case "4":
			$("div.event_fields").fadeOut("slow");
		break;
		case "5":
			$("div.event_fields").fadeOut("slow");
		break;
		case "6":
			$("div.event_fields").fadeOut("slow");
		break;
		case "7":
			$("div.event_fields").fadeOut("slow");
		break;
	}
});
});

<select name="event_type_id">
					<option>Select Event Type</option>
					<option value="2">Events Student</option>
					<option value="3">Events Faculty/Staff</option>
					<option value="1">Events FS & Students</option>
					<option value="5">Announcements Student</option>
					<option value="6">Announcements Faculty/Staff </option>
					<option value="7">Announcements FS & Students</option>
					<option value="4">Food Item</option>
				</select>

 

<div class="event_fields" style="display: none">Display Events</div>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.