动态表格的问题 [英] problems with dynamic forms

查看:51
本文介绍了动态表格的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用表单中的图层隐藏/显示

表单的一部分,但我的代码似乎没有工作,我需要一些帮助

调试它。


我没有收到错误导致调试代码变得困难,

但是我我正在收到警报(getStyleObject中的break 4);这使得

我认为这是一个浏览器兼容性问题(我正在运行IE 6.0)。

无论如何,代码如下

函数getStyleObject(objectId){

alert(" begin getSyleObject");

if(document.getElementById&& document.getElementById(objectId)){

alert("在getStyleObject中删除1);

返回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 ("在getStyleObject中断3);

返回document.layers [objectId];

}

else {

alert(getStyleObject中的break 4);

返回false;

}

alert(" end getSyleObject") ;

}

函数suspendSpouse(objectId){

alert(" begin suspendSpouse");

var styleObject = getStyleObject(objectId );

alert(" break1 in suspendSpouse");

if(styleObject){

styleObject.visibility =" hidden" ;

alert(" break in suspendSpouse");

返回true;

}

else {

alert(" break 3 in suspendSpouse");

返回false;

}

alert(" ; end suspendSpouse");

}


函数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 {

返回false; < br $>
}

alert(" end suspendSpouse");

}

和表单的重要部分如下

< tr>

< td class =" question">检查配偶是否会来:< / td>

< td>< input type =" radio"名称= QUOT; Spouse_Attend" value ="是"

onClick =" resumeSpouse(spouseLayer);">



< input type =" ;无线电"名称= QUOT; Spouse_Attend" value =" No"

onClick =" suspendSpouse(spouseLayer);">



< / td>

< / tr>

< div id =" spouseLayer"风格= QUOT;位置:相对; ">

< tr>

< td class =" question">配偶的名字:< / td>

< td>< input type =" text" name =" Spouse_First_Name"

maxlength =" 30">< / td>

< / tr>

< tr>

< td class =" question"> Spouse'的姓氏:< / td>

< td>< input type = "文本" name =" Spouse_Last_Name"

maxlength =" 30">< / td>

< / tr>

< tr>

< td class =" question"> Spouse'的联系电子邮件< / td>

< td>< input type ="文本"名称= QUOT; Spouse_email" maxlength =" 70">< / td>

< / tr>

< tr>

< td class =" question">配偶需要吃素食:< / td>

< td>< input type =" radio"名称= QUOT; Spouse_meal_veggie" value ="是">



< input type =" radio"名称= QUOT; Spouse_meal_veggie" value =" No">



< / td>

< / tr>

< / div>

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>

推荐答案

我只是遇到IE样式属性的问题;-)它可以正常使用

Firefox。哪个有一个好的调试器,你应该试着找出

哪里有问题。

无论如何它是'document.all [objectId]" ;带括号。但你的问题是

不存在。你确定objectId吗?或者在你打电话时是否存在?
getStyleObject()?


BMR

br ********** @ wpafb.af.mil écrit:
I''m just having problems with IE style property ;-) It works fine with
Firefox. Which has a good debugger, you should try it to find out
where''s the problem.
Anyway it''s "document.all[objectId]" with brackets. But your problem is
not there. Are you sure about objectId ? Or does it exist while you call
getStyleObject() ?

BMR

br**********@wpafb.af.mil a écrit :
我'我试图在表单中使用一个图层来隐藏/显示
表单的一部分,但我的代码似乎没有工作,我需要一些帮助来调试它。

我没有收到导致代码调试困难的错误,但是我收到警报(getStyleObject中的break 4);这让我觉得这是一个浏览器兼容性问题(我正在运行IE 6.0)。
无论如何,代码遵循
函数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;
}
if 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");
}
函数suspendSpouse(objectId){
alert(" begin suspendSpouse");
var STYL eObject = getStyleObject(objectId);
alert(" suspendSpouse中的break 1);
if(styleObject){
styleObject.visibility =" hidden";
alert( 在suspendSpouse中断2;
返回true;
}
其他{
警告(在breakndSpouse中断3);
返回false;
}
alert(" end suspendSpouse");


函数resumeSpouse(objectId){
alert(" check yes");
alert(" begin resumeSpouse");
var styleObject = getStyleObject(objectId);
alert(" break1 in resumeSpouse");
if(styleObject){
styleObject.visibility =" visible" ;;
return true;
}
else {
return false;
}
alert(" end suspendSpouse");
}
表格的重要部分如下< tr>
< td class =" question">检查配偶是否会来: < / td>
< td>< input type = "无线电"名称= QUOT; Spouse_Attend" value =" Yes"
onClick =" resumeSpouse(spouseLayer);">

< input type =" radio"名称= QUOT; Spouse_Attend" value =" No"
onClick =" suspendSpouse(spouseLayer);">

< / td>
< / tr>
< div id =" spouseLayer"风格= QUOT;位置:相对; ">
< tr>
< td class =" question">配偶的名字:< / td>
< td><输入类型= QUOT;文本" name =" Spouse_First_Name"
maxlength =" 30">< / td>
< / tr>
< tr>
< td class =" ;问题">配偶的姓氏:< / td>
< td>< input type =" text" name =" Spouse_Last_Name"
maxlength =" 30">< / td>
< / tr>
< tr>
< td class =" ;问题">配偶'的联系电子邮件< / td>
< td>< input type =" text"名称= QUOT; Spouse_email" maxlength =" 70">< / td>
< / tr>
< tr>
< td class =" question">配偶需要素食者饭:< / td>
< td>< input type =" radio"名称= QUOT; Spouse_meal_veggie" value ="是">

< input type =" radio"名称= QUOT; Spouse_meal_veggie" value =" No">
没有
< / td>
< / tr>
< / div>
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>



br**********@wpafb.af .mil 说:

我正在尝试使用表单中的图层来隐藏/显示
表单的一部分,但是我的代码没有似乎没有工作,我需要一些帮助来调试它。

我没有收到一个错误,这使得调试代码很困难,
但是我收到警报(getStyleObject中的break 4);这让我觉得这是一个浏览器兼容性问题(我正在运行IE 6.0)。
无论如何,代码遵循


您的代码将是多少如果您使用任何

标准缩进方案,则更容易阅读。


函数getStyleObject(objectId){
onClick =" resumeSpouse(spouseLayer) );">

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
Your code would be MUCH easier to read if you used any of
the standard indentation schemes.

function getStyleObject (objectId) { onClick="resumeSpouse(spouseLayer);">




你的代码期待一个可以传递给

getElementById的objectId,但是你传递了一个全局引用div,

而不是。在''spouseLayer''周围加上单引号(在两个onclick

处理程序中)。



Your code is expecting an objectId that can be passed to
getElementById, but you''re passing a global reference to the div,
instead. Put single quotes around ''spouseLayer'' (in both onclick
handlers).


我接受了你的建议然后运行它在Firefox中。我收到错误spouseLayer

未定义。

这并没有对这个问题有所了解。 spouseLayer定义为

div的名称。

I took your advice and ran it in Firefox. I got the error "spouseLayer
is not defined".
That doesn''t shed much light on the problem. spouseLayer is defined as
the name of the div.


这篇关于动态表格的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆