Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Junior Member
    Join Date
    Sep 2005
    Posts
    2
    Member #
    11384
    I have a dropdown menu on one page and the default option in the dropdown is the first field, i made this by inserting <Option Selected>
    If I select an option and it brings me to the relevant page, then i click on the back button it doesnt default the option in the drop down back to the first option again. Instead it defaults it to the last option I selected.
    Is there any way I can get this to default again even after clicking on the back button.
    Thanks

  2.  

  3. #2
    Senior Member Rince's Avatar
    Join Date
    Nov 2004
    Posts
    183
    Member #
    8318
    You would have to use some javascript to reset the dropdown combo box for you or reload the page to reset everything.

  4. #3
    Junior Member
    Join Date
    Sep 2005
    Posts
    2
    Member #
    11384
    Great, I dont know why I didnt think of that. I think i may have found some code that will reload the page and reset everything when i click on the back button. I will update with the code as soon as i have tested it.
    Thanks

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, this should do it:
    Code:
    function resetSelected()
    {
        document.getElementById( 'select' ).selectedIndex = 0;
    }
    Assuming the default selected you want is the first one.

    Then, a simple
    HTML Code:
    <body onload="resetSelected();">
    should call it at the appropriate time.

  6. #5
    Senior Member Rince's Avatar
    Join Date
    Nov 2004
    Posts
    183
    Member #
    8318
    Shadowfiend code won't work as clicking back does not reload so the onload event won't be triggered. However, something along that lines would be how to go.

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Wait... What? A back button hit won't call onload? That's seriously messed up...

  8. #7
    Senior Member Rince's Avatar
    Join Date
    Nov 2004
    Posts
    183
    Member #
    8318
    That's seriously messed up...
    Well, not by default. You can change your browsers settings to that clicking back does reload - but it's not a given that one follows the other for all browsers everywhere.

  9. #8
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Well, having the code in the <head> of your document, outside of any function will do what you wish, as it will run every time the page is accessed.

    Code:
    <html>
    <head>
    <title></title>
    <script type="text/javascript">
    document.getElementById( 'select' ).selectedIndex = 0;
    </script>
    </head>


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:13 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com