I have two drop down menus on my site. The first menu has two options and the second menu has five options.
The user selects an item from the first menu and an item from the second menu. Then I want him/her to press a submit button and depending on his/her choices, they are taken to a particular web site.
Can I use PHP to accomplish this? My thought process is that I would capture the choices into variables. Then write an If/Then statement - if option a and option b selected, then take the user to this site. Am I on the right path?
You can determine where to redirect the user in a landing page (where the form is to be posted/submitted) which is an extra effort but can make it possible only with PHP.
Extra effort i mean here is that extra step needs here if we use PHP to do so because the form should be submitted in a different or even in the same page first and then determine where to redirect. So if we use JavaScript then it will determine in the client side itself so does not require extra server request.
Ah, I see, and in principle I agree. Unfortunately not everyone supports js though, so you will be building a form that is broken to a number of users, just to save a tenth of a second for some headers to be sent.
Agreed there might be some browsers that does not always support JS and it can be easily disabled in any of the browsers. If anyone disables JS in their browsers intentionally that is their problem. But the browsers that does not support JS or those PCs (except cell phones) that do not have the browsers which supports JS are not worthy enough because this is the age of interactive and easy accessing websites. Although there are some of the sites (like gmail, etc) runs even if the browser does not support JS that means they need to have two versions of their sites. And to make the webpages easy accessible (like access everything without page load) JS/AJAX is the only technology AFAIK.
So personally I don’t want to develop the websites that is for those who does not want to use JS and I don’t worry about that. That is my personal opinion.
Er, we’re talking about a simple redirect. You can’t seriously be advocating using a method that doesn’t always work over one that does to save .1 seconds?