Use the same java script several different times in one document in a table

M

moda7884

I am a beginner and trying to figure this out? How can I get another
version of the javascript to appear in another table cell using the
same script? I have to use the same script 8 different times with the
same team names? Thank you in advance.

Here is the code:
<html>
<head>
<title>Untitled</title>
<style type="text/css">
..dropcontent{
width: 300px;
height: 140px;
background-color: #fa006b;
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>
</head>

<body>
<Table border="1">
<tr>

<td>
<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>

<div id="dropmsg2" class="dropcontent">
Joan T.
<br>
June G.
<br>
Alice G.
<br>
Sandy B.
</div>

<div id="dropmsg3" class="dropcontent">
Mary B.
<br>
Amy S.
<br>
Carol C.
<br>
Dee V.
</div>

<div id="dropmsg4" class="dropcontent">
Bev W.
<br>
Fran D.
<br>
Barb F.
<br>
Gerry B.
</div>

<div id="dropmsg5" class="dropcontent">
Blind
<br>
Lynda F.
<br>
Gail J.
<br>
Val B.
</div>

<div id="dropmsg6" class="dropcontent">
Helen N.
<br>
Sandy S.
<br>
Pat D.
<br>
Blind
</div>

<div id="dropmsg7" class="dropcontent" >
Dora F.
<br>
Yo P.
<br>
Minnie C.
<br>
Blind
</div>

<div id="dropmsg8" class="dropcontent" div align="center">
You Must Bowl NO <br>
LESS THAN ( <INPUT TYPE=text NAME=PPG SIZE=2 MAXLENGTH=3> ) To <br>
Take A Point Per Game!!!
</div>

</form>
</td>

<td>
<form name="dropmsgform1">
<select name="dropmsgoption1" size="1" style="width:275"
onChange="expandone()">
<option selected>JavaScript?</option>
<option>Java</option>
<option>DHTML</option>
</select>
<br>

<div id="dropmsg0" class="dropcontent">
JavaScript is cool.
</div>

<div id="dropmsg1" class="dropcontent">
Html rocks.
</div>

<div id="dropmsg2" class="dropcontent">
DHTML is awesome.
</div>
</form>
</td>

</tr>
</table>
</body>
</html>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top