<Script language="JavaScript">
<!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
//-->
</SCRIPT>
<FORM NAME="form1">
<SELECT NAME="select" ONCHANGE="goto(this.form)" SIZE="1">
<OPTION VALUE="">-------Choose a Selection-------
<OPTION VALUE="index.htm">Home
<OPTION VALUE="web_development.htm">Web Development
<OPTION VALUE="html_codes.htm">HTML Tips
<OPTION VALUE="html_codes_chart.htm">HTML Code Chart
<OPTION VALUE="javascript_codes.htm">JavaScript Codes
<OPTION VALUE="216_color_chart.htm">Color Code Chart</SELECT>
</FORM>
Please 'Mark as Answer' if my post helped you
--------------------------------------------------
Muhammad Amin
محمد امين
sriramabi
Contributor
4351 Points
1277 Posts
Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 17, 2012 02:26 PM|LINK
hai All
i have one html dropdownlist
<select class="styledselect"> <option value="0">All</option> <option value="1">Products</option> <option value="2">Categories</option> <option value="3">Clients</option> <option value="4">News</option> </select>i want select values Products ,All and select any values ,this time redirect from default (Another)page ..How is it?"pls help me..
Amin.Mirzapo...
Member
546 Points
98 Posts
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 17, 2012 02:35 PM|LINK
Try to use asp.net DropDownList control instead:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" onselectedindexchanged="DropDownList1_SelectedIndexChanged"> <asp:ListItem Value="0">All </asp:ListItem> <asp:ListItem Value="1">Products</asp:ListItem> <asp:ListItem Value="2">Categories</asp:ListItem> <asp:ListItem Value="3">Clients</asp:ListItem> <asp:ListItem Value="4">News</asp:ListItem> </asp:DropDownList>1- In the properties window of your dropdown list enable AutoPostback.
2- in the designer doubleclick on the dropdown list, this will rise when selected_index changes
3- in the generated event handler write proper logic for redirection:
mameenkhn
Contributor
2026 Points
391 Posts
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 17, 2012 02:36 PM|LINK
http://www.web-source.net/javascript_redirect_box.htm
<Script language="JavaScript"> <!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development function goto(form) { var index=form.select.selectedIndex if (form.select.options[index].value != "0") { location=form.select.options[index].value;}} //--> </SCRIPT> <FORM NAME="form1"> <SELECT NAME="select" ONCHANGE="goto(this.form)" SIZE="1"> <OPTION VALUE="">-------Choose a Selection------- <OPTION VALUE="index.htm">Home <OPTION VALUE="web_development.htm">Web Development <OPTION VALUE="html_codes.htm">HTML Tips <OPTION VALUE="html_codes_chart.htm">HTML Code Chart <OPTION VALUE="javascript_codes.htm">JavaScript Codes <OPTION VALUE="216_color_chart.htm">Color Code Chart</SELECT> </FORM>--------------------------------------------------
Muhammad Amin
محمد امين
bbcompent1
All-Star
33873 Points
8776 Posts
Moderator
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 17, 2012 02:37 PM|LINK
Doubleclick your dropdown list and then make the code like this:
private void DropDownList1_OnChange(object sender, EventArgs e) { if (DropDownList1.SelectedValue == "1") { Response.Redirect("~/Products.aspx"); } elseif (DropDownList1.SelectedValue == "2") { Response.Redirect("~/Categories.aspx"); } elseif (DropDownList1.SelectedValue == "3") { Response.Redirect("~/Clients.aspx"); } elseif (DropDownList1.SelectedValue == "4") { Response.Redirect("~/News.aspx"); }sriramabi
Contributor
4351 Points
1277 Posts
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 17, 2012 02:52 PM|LINK
thanks All ..I know all answer is right.But i m use my way
script type="text/javascript"> function checkValues() { var selectedValue = document.getElementById('AdminDropDown').value; debugger; if (selectedValue == "1") { window.location = "ManageUsers.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "2") { window.location = " ManageArticles.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "3") { window.location = "ManageProducts.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "4") { window.location = "ManageOrders.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "5") { window.location = "ManageUnapprovedPosts.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "6") { window.location = "AddEditArticle.aspx" document.getElementById('AdminDropDown').value = selectedValue } else { window.location = "~/Admin/Default.aspx" document.getElementById('AdminDropDown').value = selectedValue } } </script><select id="AdminDropDown" class="styledselect" onchange="checkValues();"> <option value="0">All</option> <option value="1">ManageUsers</option> <option value="2">Manage Articles</option> <option value="3">Manage Store Catalog</option> <option value="4">Manage Orders</option> <option value="5">Manage UnApproved Posts</option> <option value="6">Post New Articles</option> </select>Its working Well.But i am select all values and goes to another page.But dropdown Select Value 0.i want display selected value in dropdown.
Its any time Show All(Value=0)..pls help me
pls help me thank u
sriramabi
Contributor
4351 Points
1277 Posts
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 18, 2012 05:21 AM|LINK
any one help me
Amin.Mirzapo...
Member
546 Points
98 Posts
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 18, 2012 05:34 AM|LINK
Allright I got your problem. I think you should add another option, something like: "Please select....":
<select id="AdminDropDown" class="styledselect" onchange="checkValues();"> <option value="-1">Please Select...</option> <option value="0">All</option> <option value="1">ManageUsers</option> <option value="2">Manage Articles</option> <option value="3">Manage Store Catalog</option> <option value="4">Manage Orders</option> <option value="5">Manage UnApproved Posts</option> <option value="6">Post New Articles</option> </select>then:
<script type="text/javascript"> function checkValues() { var selectedValue = document.getElementById('AdminDropDown').value; debugger; if (selectedValue == "-1") { return; } if (selectedValue == "1") { window.location = "ManageUsers.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "2") { window.location = " ManageArticles.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "3") { window.location = "ManageProducts.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "4") { window.location = "ManageOrders.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "5") { window.location = "ManageUnapprovedPosts.aspx" document.getElementById('AdminDropDown').value = selectedValue } else if (selectedValue == "6") { window.location = "AddEditArticle.aspx" document.getElementById('AdminDropDown').value = selectedValue } else { window.location = "~/Admin/Default.aspx" document.getElementById('AdminDropDown').value = selectedValue } } </script>Watch out highlighted changes!
Good Luck!
sriramabi
Contributor
4351 Points
1277 Posts
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 18, 2012 05:46 AM|LINK
hi Amin.Mirzapour
no luck.Its Not Working.This time select any item.but selected value -1 only.same problem
thanks for u r help.
Amin.Mirzapo...
Member
546 Points
98 Posts
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 18, 2012 05:57 AM|LINK
I think it is normal behavior, when user had'nt select an option("select a choice" is selected by default) it should redirect to another page.
but if you wanna have a more active control you can roll back my recommanded changes on the post above and try this instead:
abiruban
All-Star
16310 Points
2773 Posts
Re: Pls Help Me, Redirect to another page using MasterPage DropDownList
Apr 18, 2012 12:00 PM|LINK
Hi,
you can using jquery document.ready function
and store the ddl selected value hidden field then reasign the value
***DON'T FORGET TO CLICK “MARK AS ANSWER” ON THE POST IF HELPED YOU.