Please help -- How to run script several times within one document

Discussion in 'Javascript' started by ThunStorm, Feb 15, 2006.

  1. ThunStorm

    ThunStorm Guest

    Please help!!! I have a script that I am able to run one time. After
    adding a second phase to run the script the script bugs out. How can I
    get the script to run several times and pull the same data?

    Here is what I am using:

    <head>
    <title>Untitled</title>
    <style type="text/css">
    ..dropcontent{
    width: 300px;
    height: 140px;
    display:block;
    }
    </style>

    <script type="text/javascript">

    if (document.getElementById){
    document.write('<style type="text/css">\n')
    document.write('.dropcontent{display:none;}\n')
    document.write('</style>\n')
    }

    function contractall(){
    if (document.getElementById){
    var inc=0
    while (document.getElementById("dropmsg"+inc)){
    document.getElementById("dropmsg"+inc).style.display="none"
    inc++
    }
    }
    }

    function expandone(){
    if (document.getElementById){
    var selectedItem=document.dropmsgform.dropmsgoption.selectedIndex
    contractall()
    document.getElementById("dropmsg"+selectedItem).style.display="block"
    }
    }

    if (window.addEventListener)
    window.addEventListener("load", expandone, false)
    else if (window.attachEvent)
    window.attachEvent("onload", expandone)

    </script>
    ================
    Here is the body:
    <form name="dropmsgform">

    <select name="dropmsgoption" size="1" style="width:175"
    onChange="expandone()">
    <OPTION>Select Team
    <OPTION>#1 Lucky Strikes
    <OPTION>#2 Morn-D-Lites
    <OPTION>#3 Pin-Up's
    <OPTION>#4 Pin Pals
    <OPTION>#5 Dreamers
    <OPTION>#6 Ups + Downs
    <OPTION>#7 Alley Cats
    <OPTION>#8 Blind
    </SELECT>
    &nbsp; &nbsp;&nbsp;
    <INPUT TYPE=text NAME=ihg1 SIZE=2 MAXLENGTH=4>

    <div id="dropmsg0" class="dropcontent">
    ???
    </div>

    <div id="dropmsg1" class="dropcontent">
    Karen L.
    <br>
    Marlene T.
    <br>
    Joyce A.
    <br>
    Mickey Z.
    </div>
     
    ThunStorm, Feb 15, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jimi Hullegård
    Replies:
    15
    Views:
    1,320
    Raymond DeCampo
    Sep 6, 2005
  2. Tony Prichard
    Replies:
    0
    Views:
    791
    Tony Prichard
    Dec 12, 2003
  3. jblau
    Replies:
    2
    Views:
    435
    Ian Collins
    Jan 14, 2007
  4. Abby Lee
    Replies:
    5
    Views:
    482
    Abby Lee
    Aug 2, 2004
  5. Replies:
    0
    Views:
    119
Loading...

Share This Page