A newbie's question

De qué se hablaPurely Programmers

Únase a LibraryThing para publicar.

A newbie's question

Este tema está marcado actualmente como "inactivo"—el último mensaje es de hace más de 90 días. Puedes reactivarlo escribiendo una respuesta.

Feb 14, 2009, 5:27am

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.

Feb 14, 2009, 5:42am

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.

Editado: Feb 14, 2009, 5:43am

No, it doesn't.

Feb 14, 2009, 9:42am

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

Feb 17, 2009, 8:38am

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

Feb 17, 2009, 8:50am

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

Feb 17, 2009, 11:29am

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;

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;

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.

Feb 17, 2009, 12:07pm

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. ;)

Feb 17, 2009, 1:50pm

> 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 :)

Feb 17, 2009, 5:40pm

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