Contractible Header Javascript

saf01 14 Nov, 2007
Hi. Im new to using Chronoforms. I have a script which I am unable to work out using Chronoforms and it doesn't work. This is ComboBox Viewer script from DynamicDrive.

This is my Javascript I pasted in Javascript section :

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)

This is the Form HTML:

<select name="dropmsgoption" size="1" style="width:300" onChange="expandone()">
<option selected>Name</option>
<option>Address</option>
<option>Email</option>
</select>
<br>

<div id="dropmsg0" class="dropcontent">
Please type your name here...
</div>

<div id="dropmsg1" class="dropcontent">
Please type your address here...
</div>

<div id="dropmsg2" class="dropcontent">
Please type your email here...
</div>

Please can someone help.<br><br>Post edited by: saf01, at: 2007/11/14 14:30
GreyHead 14 Nov, 2007
Hi saf01,

I'm no JavaScript expert but I think that the problem is that the script expects the form to have the name 'dropmsgform' whilst it's actually called something like 'ChronoContact_dropmsgform'

Bob
saf01 14 Nov, 2007
Hi Bob. Thx for reply. I used another script like this from javascript.internet site and it all works now.

Cheers.
This topic is locked and no more replies can be posted.