PDA

View Full Version : Help with function toggle.lyr



longman
Mar 27th, 2007, 10:57 AM
Hi all,

- This is my first post, so I apologise if it's old ground but I could not find the answer anywhere. I am not an expert, I am self taught but am really enjoying myself with this and a bit of ASP stuff.

- I am creating basic html pages for use in late version IE, with forms to input details and then using "function createDocument" to generate a nicely formatted official document saved to the clipboard at the end.

- I am using radio buttons as options with layers depending on the radio button pressed for further input.

- I am using the following code to toggle the layers:

======================================

Function toggleLyr(radObj)
{
whichObj = eval(“document.all.” + radObj)

for (i=0;i<whichObj.length;i++)
if (whichObj[i].checked == true)
{

lyrObjName = “lyr” + radObj.substring(3,radobj.length)
lyrObj = eval(“document.all.” + lyrObjName)

if (document.getElementById(lyrObjName + i ))
{
lyrObjSrc = eval(“document.all.” + lyrObjName + i )

if (lyrObjSrc.innerHTML.indexOf (“ // “) >= 0)
codeStr=
lyrObjSrc.innerHTML.substring(lyrObjSrc.innerHTML.indexOf(“ // “)+2, lyrObjSrc.innerHTML.lastIndexOf(“ // “))
else
codeStr= “”

if (lyrObj != undefined)
lyrObj.innerHTML =
lyrObjSrc.innerHTML.replace(“ // “codeStr+”//”,””)

if (codeStr.length > 0) eval(codeStr)
}
else
{
if (lyrObj != undefined)
lyrObj.innerHTML = “”
}
}
}

======================================

- I am also using a basic Function validateRad(radObj) segment to populate the rad field above.

- Anyway, my issue is with nested layers. Does anyone know how I can create layers within layers using the toggle method as above?

- My nested layers seem to work if the layer div does not need any further input areas e.g:

<div id=lyrovertime0 style='display:none;'>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
//alert ("please ensure you report for overtime 30mins prior to work.")//
</tr>
</table>
</div>

- The above code when nested will create the popup window with the alert message without any problems. If however the nested layer requires any input fields or other formatting it will not work. For example the following does not work when nested:

<div id=lyrovertime1 style='display:none;'>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td style='width:160px;'>Time of arrival:</td>
<td><input size=24 name=txtarrivaltime></td>
</tr>
</table>
</div>

- There are no errors or any other warnings on the page when the radio button is pressed, simply, nothing happens.
- An example of the radio inputs is as follows:


<hr style=width:100% align=left>
<table style='width:500;' cellspacing=0 cellpadding=0 border=0>
<tr>
<td> Will you be attending overtime this weekend?&nbsp;<input type=radio name=radovertime onclick="javascript:toggleLyr(this.name);" value=Yes> Yes <input type=radio name=radovertime onclick="javascript:toggleLyr(this.name);" value= No> No
</td>
</tr>
</table>
<div id=lyrovertime>
</div>

- Apart from the nested layer issues everything else works perfectly.
- Any assistance would be appreciated. I like to keep using this toggle method if possible.

Thanks!!

Longman