I'm not sure if this is the right description, as I'm new to web development, so I will try to explain as good as possible. I have a form that loads information the user previously entered so they can modify data. One of the pulldowns is a javascript that says if they choose one of the options to then show another layer of the form. It works fine when they change the pulldown option, but the problem is if they had already entered previously the option that shows the layer, on loading the page it doesnt show the layer until they change the pulldown option to something else and then back again. The coldfusion query gets the pulldown options from a table and displays the option first that the user had (if they had) previously entered. And again, if that option happens to be the one that shows the hidden layer, it wont show it on loading the page. I've taken out all irrevelent data so dont worry about the little things missing...
<head>
<script language="JavaScript">
function show(el) {
txt = (el[el.selectedIndex].text
);
if (document.all) {
Construction.style.display
= (txt == 'Construction') ? "" : "none";
} else {
document.layers["Construct
ion"].visi
bility = (txt == 'Construction') ? "visible" : "none";
}
}
</script>
</head>
<body>
<tr>
<td>
<cfquery name="qPurpose" datasource="psfloan">
SELECT drop6
FROM dropdown
WHERE drop6 IS NOT NULL
</cfquery>
<select name="LoanPurpose" onChange="show(this)";>
<cfloop query="qPurpose">
<CFIF #qClient.LoanPurpose# is #qPurpose.drop6#>
<OPTION VALUE="#drop6#" SELECTED>#drop6#</OPTION>
<CFELSE>
<OPTION VALUE="#drop6#">#drop6#</O
PTION>
</cfif>
</cfloop>
</select>
</td>
</tr>
<DIV ID="Construction" style="position:relative;"
>
Show this layer
</div>
<script language="JavaScript">
if (document.layers) {
document.layers["Construct
ion"].visi
bility = "hidden";
} else {
Construction.style.display
= "none";
}
</script>
</body>
Start Free Trial