B
brian.newman
I'm trying to use a layer inside a form to hide/reveal a part of the
form, but my code doesn't seem to be working and I need some help
debugging it.
I'm not getting an error which has made it difficult to debug the code,
but I am getting the alert ("break 4 in getStyleObject"); which makes
me think this is a browser compatability issue (I'm running IE 6.0).
Anyway, the code follows
function getStyleObject (objectId) {
alert ("begin getSyleObject");
if (document.getElementById && document.getElementById(objectId)) {
alert ("break 1 in getStyleObject");
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId)) {
alert ("break 2 in getStyleObject");
return document.all(objectId).style;
}
else if (document.layers && document.layers[objectId]) {
alert ("break 3 in getStyleObject");
return document.layers[objectId];
}
else {
alert ("break 4 in getStyleObject");
return false;
}
alert ("end getSyleObject");
}
function suspendSpouse(objectId) {
alert ("begin suspendSpouse");
var styleObject = getStyleObject (objectId);
alert ("break 1 in suspendSpouse");
if (styleObject) {
styleObject.visibility = "hidden";
alert ("break 2 in suspendSpouse");
return true;
}
else {
alert ("break 3 in suspendSpouse");
return false;
}
alert ("end suspendSpouse");
}
function resumeSpouse (objectId) {
alert ("check yes");
alert ("begin resumeSpouse");
var styleObject = getStyleObject (objectId);
alert ("break 1 in resumeSpouse");
if (styleObject) {
styleObject.visibility = "visible";
return true;
}
else {
return false;
}
alert ("end suspendSpouse");
}
and the significant part of the form follows
<tr>
<td class="question">Check if Spouse will come:</td>
<td><input type="radio" name="Spouse_Attend" value="Yes"
onClick="resumeSpouse(spouseLayer);">
Yes
<input type="radio" name="Spouse_Attend" value="No"
onClick="suspendSpouse(spouseLayer);">
No
</td>
</tr>
<div id="spouseLayer" style="position:relative; ">
<tr>
<td class="question">Spouse's First Name:</td>
<td><input type="text" name="Spouse_First_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Last Name:</td>
<td><input type="text" name="Spouse_Last_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Contact Email</td>
<td><input type="text" name="Spouse_email" maxlength="70"></td>
</tr>
<tr>
<td class="question">Spouse will require a vegetarian meal:</td>
<td><input type="radio" name="Spouse_meal_veggie" value="Yes">
Yes
<input type="radio" name="Spouse_meal_veggie" value="No">
No
</td>
</tr>
</div>
form, but my code doesn't seem to be working and I need some help
debugging it.
I'm not getting an error which has made it difficult to debug the code,
but I am getting the alert ("break 4 in getStyleObject"); which makes
me think this is a browser compatability issue (I'm running IE 6.0).
Anyway, the code follows
function getStyleObject (objectId) {
alert ("begin getSyleObject");
if (document.getElementById && document.getElementById(objectId)) {
alert ("break 1 in getStyleObject");
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId)) {
alert ("break 2 in getStyleObject");
return document.all(objectId).style;
}
else if (document.layers && document.layers[objectId]) {
alert ("break 3 in getStyleObject");
return document.layers[objectId];
}
else {
alert ("break 4 in getStyleObject");
return false;
}
alert ("end getSyleObject");
}
function suspendSpouse(objectId) {
alert ("begin suspendSpouse");
var styleObject = getStyleObject (objectId);
alert ("break 1 in suspendSpouse");
if (styleObject) {
styleObject.visibility = "hidden";
alert ("break 2 in suspendSpouse");
return true;
}
else {
alert ("break 3 in suspendSpouse");
return false;
}
alert ("end suspendSpouse");
}
function resumeSpouse (objectId) {
alert ("check yes");
alert ("begin resumeSpouse");
var styleObject = getStyleObject (objectId);
alert ("break 1 in resumeSpouse");
if (styleObject) {
styleObject.visibility = "visible";
return true;
}
else {
return false;
}
alert ("end suspendSpouse");
}
and the significant part of the form follows
<tr>
<td class="question">Check if Spouse will come:</td>
<td><input type="radio" name="Spouse_Attend" value="Yes"
onClick="resumeSpouse(spouseLayer);">
Yes
<input type="radio" name="Spouse_Attend" value="No"
onClick="suspendSpouse(spouseLayer);">
No
</td>
</tr>
<div id="spouseLayer" style="position:relative; ">
<tr>
<td class="question">Spouse's First Name:</td>
<td><input type="text" name="Spouse_First_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Last Name:</td>
<td><input type="text" name="Spouse_Last_Name"
maxlength="30"></td>
</tr>
<tr>
<td class="question">Spouse's Contact Email</td>
<td><input type="text" name="Spouse_email" maxlength="70"></td>
</tr>
<tr>
<td class="question">Spouse will require a vegetarian meal:</td>
<td><input type="radio" name="Spouse_meal_veggie" value="Yes">
Yes
<input type="radio" name="Spouse_meal_veggie" value="No">
No
</td>
</tr>
</div>