A newbie's question

DiskuteraPurely Programmers

Bara medlemmar i LibraryThing kan skriva.

A newbie's question

Denna diskussion är för närvarande "vilande"—det sista inlägget är mer än 90 dagar gammalt. Du kan återstarta det genom att svara på inlägget.

1polomontana
feb 14, 2009, 5:27 am

I'm new to this and I am writing HtML code for a website I'm building.

I have the drop down window but how do you direct the selections in the drop down menu to different destinations?

I'm stuck on my form, action line and my drop down menu works but only for the one option in my action line.

So when option A or option B are picked in the drop down menu, if the person hits A or B, how can I direct them to different destinations?

Do I take out my action line?

Thanks in advance.

Just a quick example of what I'm saying.

I have

I have my drop down menu set up but every time I hit submit it's directed to the same option.

2Noisy
feb 14, 2009, 5:42 am

Posting examples of HTML will be very difficult, because LT will see the first < and start looking for an entity that it recognises. You could try replacing all your < symbols with &lt;. I don't know if <pre> works.

3Noisy
Redigerat: feb 14, 2009, 5:43 am

No, it doesn't.

4jjwilson61
feb 14, 2009, 9:42 am

You could just replace all your angle brackets with squiggly brackets for the purpose of posting here.

5Makis
feb 17, 2009, 8:38 am

LT forums really should have either a PRE or CODE tag...

6felius
feb 17, 2009, 8:50 am

You could use http://pastebin.com/ and post a link.

7wimble
feb 17, 2009, 11:29 am

If I'm understanding correctly:
You've got an HTML form, with an action.
Within that form you've got a select list, with multiple options.
You want to send the user to a different URL according to the option they select from the list?

You can't do it (is the technically correct answer).
What you can do is put a switch (or series of if branches) in the one thing they get directed to, which renders entirely different HTML, according to the selected option:
IF option='A' THEN draw_page_1;
ELSIF option='B' THEN draw_page_2;
etc.

What you can do though, is include HTML redirection on each of those pages (See http://en.wikipedia.org/wiki/URL_redirection#Techniques for the technicalities). What then happens is that the user initially comes to your one available action, and the above code is replaced with:
IF option='A' THEN redirect_to_page_1;
ELSIF option='B' THEN redirect_to_page_2;
etc.

After which the user is redirected to the appropriate ultimate page. This does get more complicated if you want to preserve other values they passed with the form though.

8conceptDawg
feb 17, 2009, 12:07 pm

Or use Javascript to handle the form click. But that's really getting into a whole other language that you don't want to deal with. But you asked. ;)

9wimble
feb 17, 2009, 1:50 pm

> 8

True, I forgot the Javascript embellishment after the basic explanation. I've spent too many years writing server-side code, without relying on JS :)

10utoxin
feb 17, 2009, 5:40 pm

For posting code examples for people to look at, I reccomend PasteBin: http://pastebin.com/