Results 1 to 4 of 4

Thread: what is the script to create a button and...

  1. #1
    Join Date
    Jul 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default what is the script to create a button and...

    I am trying to create a button (onClick) that will get to a specified page. Can anyone help?

    Thanks

    JL

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    HTML Code:
    <button onclick="window.location.href='newpage.htm';">Go to newpage.htm</button>
    If you're willing to take a little time over it, you'll be better off using a link with a outset border-style and a grey background to make it LOOK like a button, thus making it work in non-JS browsers.
    HTML Code:
    <a href="newpage.htm" style="text-decoration: none; border-style: outset; background-color: grey; border-color: grey; border-width: 3px; color: black;" onclick="this.style.borderStyle='inset';">Go to newpage.htm</a>
    Or, you can use a form with no inputs:
    HTML Code:
    <form action="newpage.htm" method="post">
    <input type="submit" value="Go to newpage.htm"/>
    </form>
    Tweak as required.
    Last edited by Twey; 07-16-2005 at 09:10 AM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default on the third option...

    say if I would like to allow guests to enter/select on which state they're in in a text field, then (as they click on a button) I would like the site to direct accordingly.... what would be the steps for this type of action....???


    thanks!

    JL

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If you have a server-side language installed, that would be better; however, if you don't, you'd use Javascript like so:
    HTML Code:
    <select id="state">
    <option value="alabama.htm">Alabama</option>
    <option value="michigan.htm">Michigan</option>
    <!-- ... and so on ... -->
    </select>
    <button onclick="window.location.href=document.getElementById('state').value;">Go</button>
    If Alabama were selected, the user would be sent to alabama.htm; if Michigan were selected, the user would be sent to michigan.htm, and so on.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •