Results 1 to 7 of 7

Thread: show selected option when page loads

  1. #1
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default show selected option when page loads

    You can change the background color from a div with a select menu.

    TESTPAGE

    The first option is "transparant", this is an image (white-gray cubes).
    When the page loads the background-color is "white". Change it to e.g. "red".
    Than you can change it to "transparant" en appears the image.

    It should be the "transparant" option when the page loads.

    Anyone an idea how to do this ?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Put this right before the closing </body> tag:

    Code:
    <script type="text/javascript">
    document.getElementById('colorBG').selectedIndex = 0;
    changeBG('url(Background-No.jpg)');
    window.onunload = function(){};
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    Great ... thanks John !

    Do I have to change something on the style :
    Code:
    <option value="url(Background-No.jpg)" selected="selected" style="background-color:White; color:#000000">Transparant</option>

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Not really. You could and probably should set it to what you want it to be on page load and you could/should set the background for the BackColor2 div to that as well. But the surest way, cross browser is the code I gave you. You should probably do both. But just the code is all you need if javascript is enabled, and the thing won't work if javascript is not available.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    OK thanks.

    On my testpage everything works fine.
    But on MY PAGE there must be something wrong ...

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Looks like it's working there too. Looks like some other script is changing things after that. Ah, looks like (remove the highlighted):

    Code:
    <body onload="changeBG('WhiteSmoke');berekenAlles();load()">
    There could also be other problems, but that's probably it, and that has to be removed for it to work the way you want it to anyway.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    yes that's it
    I removed it in the code, but I had to remove it from the templates properties too.

    Thanks John, you helped me a lot of times.
    Remember this thread ?
    The solution is also on THIS PAGE. Maybe you can use it ... .

Similar Threads

  1. Ultimate Fade-in slideshow: No show until page loads
    By cgehringer in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 03-24-2012, 05:45 AM
  2. Dynamic php page - option selected
    By KevinBeyers in forum PHP
    Replies: 0
    Last Post: 11-10-2011, 10:53 AM
  3. Option has to be selected on page load
    By Yammaski in forum JavaScript
    Replies: 2
    Last Post: 03-26-2010, 10:36 AM
  4. Show image+text when page loads
    By UlrikC in forum Looking for such a script or service
    Replies: 0
    Last Post: 12-29-2009, 10:54 PM
  5. Replies: 1
    Last Post: 10-14-2006, 08:40 AM

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
  •