#1
  1. No Profile Picture
    Kimberly
    Guest
    Devshed Newbie (0 - 499 posts)
    HI, we are trying to create a form where if you enter a certain country, say candada it takes you to one page when you submit the form..and if you pick U.S.A. then it takes you to another form ...Is this going to have to involve java, or is there any way to use a variables within html?
  2. #2
  3. No Profile Picture
    scollo
    Guest
    Devshed Newbie (0 - 499 posts)
    Hi Kimberly,

    It's a little complicated, but try this:

    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE='javascript'>
    function direct (frm) {
    &nbsp;switch (frm.Country.selectedIndex) {
    &nbsp;&nbsp;case 0:
    &nbsp;&nbsp;&nbsp;frm.action="canada.html";
    &nbsp;&nbsp;&nbsp;break;
    &nbsp;&nbsp;case 1:
    &nbsp;&nbsp;&nbsp;frm.action="us.html";
    &nbsp;&nbsp;&nbsp;break;
    &nbsp;}
    &nbsp;return true;
    }
    </SCRIPT>

    </HEAD>
    <BODY>
    <FORM onSubmit="return direct(this);">
    <SELECT NAME="Country">
    &nbsp;<OPTION>Canada</OPTION>
    &nbsp;<OPTION>United States</OPTION>
    </SELECT>
    <INPUT TYPE=submit VALUE="Enter">
    </FORM>
    </BODY>
    </HTML>

    Let me know how this goes.

    -- Christopher
  4. #3
  5. No Profile Picture
    scollo
    Guest
    Devshed Newbie (0 - 499 posts)
    Incidentally, if you want the page to change as soon as the user select a country (without having to click "Submit"), the code would look like this:

    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="javascript">

    function direct (slct) {
    &nbsp;&nbsp;switch (slct.selectedIndex) {
    &nbsp;&nbsp;&nbsp;&nbsp;case 0:
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.document.location.href="canada.html";
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
    &nbsp;&nbsp;&nbsp;&nbsp;case 1:
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.document.location.href="us.html";
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
    &nbsp;&nbsp;}
    }

    </SCRIPT>
    </HEAD>

    <BODY>
    <FORM>
    &nbsp;&nbsp;<SELECT NAME="Country" onChange="direct(this);">
    &nbsp;&nbsp;&nbsp;&nbsp;<OPTION>Canada</OPTION>
    &nbsp;&nbsp;&nbsp;&nbsp;<OPTION>United States</OPTION>
    &nbsp;&nbsp;</SELECT>
    </FORM>
    </BODY>
    </HTML>

    Naturally, replace canada.html with the page that you want for Canada and replace us.html with the page that you want for the U.S.

    -- Christopher

    (I hope this works)

Similar Threads

  1. redirecting pages
    By dynasty in forum PHP Development
    Replies: 7
    Last Post: February 9th, 2004, 02:14 PM
  2. redirecting pages
    By dynasty in forum HTML Programming
    Replies: 1
    Last Post: February 5th, 2004, 02:28 PM
  3. Redirecting pages
    By andrewguppy in forum HTML Programming
    Replies: 2
    Last Post: September 4th, 2003, 07:30 AM
  4. Redirecting pages
    By aplus in forum Perl Programming
    Replies: 10
    Last Post: August 5th, 2003, 02:19 PM
  5. forms and multiple php pages
    By porsche911 in forum PHP Development
    Replies: 9
    Last Post: July 5th, 2001, 04:59 PM

IMN logo majestic logo threadwatch logo seochat tools logo