Nesting Javascripts?

G

GarryJones

Can I nest javascript to open a hidden DIV tag on a DIV tag that is
itself opened by javascript?

I have a javascript to decide which DIV tag is visible. (Code A)

In one of these DIV tags (mck04) I have a button to show a hidden
form. (Code B)

Code B works stand alone on its on html page but I get "element not
found" when I place the link to it in another DIV tag which in itself
is opened by Code A.

Code A
***************************************************************
var ids=new Array('mck01','mck02','mck03','mck04','mck05');

function switchid(id){
hideallids();
showdiv(id);
}

function hideallids(){
for (var i=0;i<ids.length;i++){
hidediv(ids);
}
}

function hidediv(id) {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'none';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'none';
}
else { // IE 4
document.all.id.style.display = 'none';
}
}
}

function showdiv(id) {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.display = 'block';
}
else {
if (document.layers) { // Netscape 4
document.id.display = 'block';
}
else { // IE 4
document.all.id.style.display = 'block';
}
}
}

*****************************
This is Code B

function InsertContent(tid) {
if(document.getElementById(tid).style.display == "none") {
document.getElementById(tid).style.display = "";
}
else {
document.getElementById(tid).style.display = "none";
}
}
**********************************

This is the code to show the mck04 tag
<a href="javascript:switchid('mck04');">Details</A>

The mck04 div is displayed and in it I have some details of a sporting
event. The idea is if they want to sign up they open the form (show1)
whilst remaining within the mck04 tag.

<div id="show1" style="display: none">
(The form code is here)
</div>

This is the link within DIV mck04 which should open show1
<a href="javascript:InsertContent('show1');">Click here to sign up</a>

Any help greatly appreciated

Garry Jones
Sweden
 

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

Forum statistics

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

Latest Threads

Top