|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Drop-Down Boxes
I want to make a drop-down box that has 7 different choices in it, and I want each choice to open a webpage with info related to the choice on it. I have my drop-down box and each choice has a value, but I am unsure what I need to do next as far as making each choice go and grab the page that the value represents.
My index page is created with frames if this matters. Thanks, Tim |
|
#2
|
|||
|
|||
|
booo to frames i say
i don't think so, i'm sure someone smart knows a good way, but my sloppy ways: when you submit, have the form submit to itself, and the first line checks request.form("dropdown") and do a case or if then's etc to response.redirect "page you want.asp", or however you load a page in frames, i don't use them so i can't tell you exactly but that's the logic.... another way around is using javascript to just open up a new window completely... Last edited by unatratnag : August 15th, 2003 at 05:55 PM. |
|
#3
|
||||
|
||||
|
Four ways to do it
I agree with unatratnag
you could have the form re post to itself and from there decide which page to view ... this will result in the new pages opening inside the frames .... if you don't want that (opening inside the frame) .. you would have the post done to the index page instead of the same page ... also this could be done by client side scripting javascripting ... let us know which way you wish to have it done (in frame or out of it) .. and which scripting is better for you "easier to learn" and we could give you more detailed guide lines |
|
#4
|
|||
|
|||
|
Undecided
Well I would rather do it in java because I'll get exactly what I want doing it that way. I would like to keep the frames and just open the pages inside the frames from the drop-down list.
Thanks guys hopefully I can get this stupid page built. |
|
#5
|
|||
|
|||
|
you can use Client Side JAVASCRIPT to acheive that pretty easily.
have your webpage link as <option value="http://www.devshed.com"> devshed </option> and a button below it which opens the url with something like this < button onClick= window.open( combo.value) > |
|
#6
|
|||
|
|||
|
here's what I got...
here's the combo box information that I have, can you help me insert the code you sent me into this so it will work correctly.
td HEIGHT="20" width="156" style="border-style: none; border-width: medium; "> <font style="font-weight: 700">Phone Directory</font><font size="2" face="Arial, MS Sans Serif, sans-serif"><small><select size="1" name="MakeId" class="FormText" onChange="SelectList(0,'make');"> <OPTION VALUE="0" SELECTED>Location</OPTION> <OPTION VALUE="1">Sixth St.</OPTION> <OPTION VALUE="2">Main St.</OPTION> <OPTION VALUE="3">Campus</OPTION> <OPTION VALUE="4">La Pine</OPTION> <OPTION VALUE="5">Gilchrist</OPTION> <OPTION VALUE="6">Lakeview</OPTION> <OPTION VALUE="7">Medford</OPTION> </select></small></font></td> </tr> </table> </body> </html> Last edited by mazbball32 : August 19th, 2003 at 02:01 PM. |
|
#7
|
|||
|
|||
|
here you go
<select size="1" name="MakeId" class="FormText" onChange="SelectList(0,'make');"> <OPTION VALUE="0" SELECTED>Location</OPTION> <OPTION VALUE="http://forums.devshed.com/t76984/s.html">Sixth St.</OPTION> <OPTION VALUE="http://www.yahoo.com">Main St.</OPTION> <OPTION VALUE="http://www.aspfree.com">Campus</OPTION> <OPTION VALUE="http://www.devguru.com">La Pine</OPTION> <OPTION VALUE="5">Gilchrist</OPTION> <OPTION VALUE="6">Lakeview</OPTION> <OPTION VALUE="7">Medford</OPTION> </select> <input type=button name="winopener" value="Go" onClick=window.open(MakeId.value)> |
|
#8
|
|||
|
|||
|
it works! but...
It all works great, but I'm getting an error in this line:
<OPTION VALUE="0" SELECTED>Location</OPTION> I'm going to attach to this post a picture of the error I'm getting. |
|
#9
|
|||
|
|||
|
well if location isn't an option and not needed, you'll probably check in javascript to not select that right? so don't give it a value at all, or if you have to for a reason i can't think of right now, say value = "". If you don't specify a value the name displayed (Location) will be what the GET/POST displays for the select.
|
|
#10
|
|||
|
|||
|
yes obviously.. Since there is no URL attached to "Location", it would fail.. I gave you a test script. It is not a bullet proof script. I dont know what you might need and if you need all the options.
One limitation of the script is that, it doesnot check for a valid URL. It expects a valid URL. So, it is unto you to fill the "option value" with valid URLs. If you dont need some of em, remove the options. |
|
#11
|
|||
|
|||
|
yea, aspman's statement makes me retract mine,
Quote:
There is no reason, use javascript to make sure you just don't select that top option. Aspman's script works fine as is and add some java validation to make sure the Location value isn't selected. |
|
#12
|
|||
|
|||
|
Thank you everyone
I've got it!!! It works great and I don't have any errors. The urls are opening in their own windows instead of within the frame, but I can deal with that. If someone knows a way to make it open within the frame then that's great, if not no biggy.
Thanks for everything |
|
#13
|
|||
|
|||
|
One more thing...
Alright first day of use went pretty good, but everyone wants it to open within the frame. I know that it's just a comand and i'm almost sure it's in this syntax:
<input type=button name="winopener" value="Go" onClick=window.refresh(MakeId.value)> can somone please let me know what the "onClick" command is to open my values inside of my frame? |
|
#14
|
|||
|
|||
|
i guess you cannot use window.open if you want to open in the same frame. I need to check some html. I will check and let you know
|
|
#15
|
|||
|
|||
|
window.open(URL, name [, features])
The documentation says, if you specify the name as the name of the frame name. you should be opening the page in that frame. I have not tried it though. so, you would be doing window.open('http://www.yahoo.com','myframe') where 'myframe' is the name of the frame |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Drop-Down Boxes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|