请帮助基本的onClick机制 [英] Help with basic onClick mechanism please
问题描述
我对JavaScript很陌生并且遇到麻烦,我认为这应该是相当容易的。
我有一个表格。
我有两个单选按钮。
我有一个隐藏的文本框。
如果单击具有值的单选按钮是的,隐藏的
字段应该可见。
我很感激帮助知道我做错了什么。这是
相关代码:
< TD WIDTH = 100%ALIGN = LEFT>
< INPUT TYPE = " HIDDEN" NAME ="机构" VALUE =" {Individuals.CS-
Appl Academic.Institution}" SIZE = 32 MAXLENGTH = 5>
< / TD>
< TD width =" 100%">
<输入类型=" radio"名称= QUOT; addInstitution" value ="是"
onClick =" choiceInstitution(this.form)">
< Input type =" radio"名称= QUOT; addInstitution" CHECKED value =" No"
onClick =" choiceInstitution(this.form)">
< / TD>
< script LANGUAGE =" JavaScript">
void choiceInstitution(theForm){
if(theForm.addInstitution [0] .checked)
{
document.theForm.getElementByID(" Institution")。vis ibility =
" visible"'';
}
}
< / script>
点击单选按钮时,值为是的,屏幕上没有任何变化
。我想知道这是不是因为
元素的类型是HIDDEN。我应该如何改变这一点,以便当我点击是单选按钮时我可以显示
显示?谢谢。
肯
I am pretty new to JavaScript and having trouble with something that
should, I think, be fairly easy.
I have one form.
I have two radio buttons.
I have a text box that is hidden.
If you click the radio button that has the value "Yes", the hidden
field should be made visible.
I would appreciate help knowing what I did wrong. Here is the
pertinent code:
<TD WIDTH=100% ALIGN=LEFT>
<INPUT TYPE="HIDDEN" NAME="Institution" VALUE="{Individuals.CS-
Appl Academic.Institution}" SIZE=32 MAXLENGTH=5>
</TD>
<TD width="100%">
<Input type="radio" name="addInstitution" value="Yes"
onClick="choiceInstitution(this.form)">
<Input type="radio" name="addInstitution" CHECKED value="No"
onClick="choiceInstitution(this.form)">
</TD>
<script LANGUAGE="JavaScript">
void choiceInstitution(theForm) {
if(theForm.addInstitution[0].checked)
{
document.theForm.getElementByID("Institution").vis ibility =
"visible"'';
}
}
</script>
When I click the radio button with the value of "Yes", nothing changes
on the screen. I''m wondering if this is because the type of the
element is HIDDEN. How should I change this so that I can get it to
display when I click the yes radio button? Thanks.
Ken
推荐答案
OccasionalFlyer写道:
[snip]
OccasionalFlyer wrote:
[snip]
>
我很感激帮助知道我做错了什么。这是
相关代码:
< TD WIDTH = 100%ALIGN = LEFT>
< INPUT TYPE = " HIDDEN" NAME ="机构" VALUE =" {Individuals.CS-
Appl Academic.Institution}" SIZE = 32 MAXLENGTH = 5>
< / TD>
>
I would appreciate help knowing what I did wrong. Here is the
pertinent code:
<TD WIDTH=100% ALIGN=LEFT>
<INPUT TYPE="HIDDEN" NAME="Institution" VALUE="{Individuals.CS-
Appl Academic.Institution}" SIZE=32 MAXLENGTH=5>
</TD>
永远不会显示HIDDEN类型的输入元素。
您需要将其更改为TEXT类型并设置样式属性
" visibility:hidden;"
An Input element of the HIDDEN type will never be displayed.
You need to change this to the TEXT type and set the style attribute to
"visibility:hidden;"
>
< TD width =" 100%">
<输入类型= QUOT;无线电"名称= QUOT; addInstitution" value ="是"
onClick =" choiceInstitution(this.form)">
< Input type =" radio"名称= QUOT; addInstitution" CHECKED value =" No"
onClick =" choiceInstitution(this.form)">
< / TD>
< script LANGUAGE =" JavaScript">
void choiceInstitution(theForm){
if(theForm.addInstitution [0] .checked)
{
document.theForm.getElementByID(" Institution")。vis ibility =
" visible"'';
}
}
< / script>
>
<TD width="100%">
<Input type="radio" name="addInstitution" value="Yes"
onClick="choiceInstitution(this.form)">
<Input type="radio" name="addInstitution" CHECKED value="No"
onClick="choiceInstitution(this.form)">
</TD>
<script LANGUAGE="JavaScript">
void choiceInstitution(theForm) {
if(theForm.addInstitution[0].checked)
{
document.theForm.getElementByID("Institution").vis ibility =
"visible"'';
}
}
</script>
你没有任何ID为机构的元素
我假设你的意思是你的HIDDEN输入元素a / name /
" Institution" ;.
给它一个机构的ID你是金色的
You don''t have any elements with an id of "Institution"
I assume you mean your HIDDEN input element which has a /name/ of
"Institution".
Give that an id of "Institution" and you''re golden
6月11日下午2:26,Dan Rumney< danrum ... @ warpmail.netwrote:
On Jun 11, 2:26 pm, Dan Rumney <danrum...@warpmail.netwrote:
OccasionalFlyer写道:
[snip]
OccasionalFlyer wrote:
[snip]
我很感激帮助知道我的意思做错了。这是
相关代码:
I would appreciate help knowing what I did wrong. Here is the
pertinent code:
< TD WIDTH = 100%ALIGN = LEFT>
< INPUT TYPE =" HIDDEN" NAME ="机构" VALUE =" {Individuals.CS-
Appl Academic.Institution}" SIZE = 32 MAXLENGTH = 5>
< / TD>
<TD WIDTH=100% ALIGN=LEFT>
<INPUT TYPE="HIDDEN" NAME="Institution" VALUE="{Individuals.CS-
Appl Academic.Institution}" SIZE=32 MAXLENGTH=5>
</TD>
永远不会显示HIDDEN类型的输入元素。
您需要将其更改为TEXT类型并设置样式属性
" visibility:hidden;"
An Input element of the HIDDEN type will never be displayed.
You need to change this to the TEXT type and set the style attribute to
"visibility:hidden;"
< TD width =" 100% ">
<输入类型=" radio"名称= QUOT; addInstitution" value ="是"
onClick =" choiceInstitution(this.form)">
< Input type =" radio"名称= QUOT; addInstitution" CHECKED value =" No"
onClick =" choiceInstitution(this.form)">
< / TD>
<TD width="100%">
<Input type="radio" name="addInstitution" value="Yes"
onClick="choiceInstitution(this.form)">
<Input type="radio" name="addInstitution" CHECKED value="No"
onClick="choiceInstitution(this.form)">
</TD>
< script LANGUAGE =" JavaScript">
void choiceInstitution(theForm){
if(theForm.addInstitution [0] .checked)
{
document.theForm.getElementByID(" Institution")。vis ibility =
" visible"'';
}
}
<script LANGUAGE="JavaScript">
void choiceInstitution(theForm) {
if(theForm.addInstitution[0].checked)
{
document.theForm.getElementByID("Institution").vis ibility =
"visible"'';
}
}
< ; /脚本>
</script>
你没有任何ID为机构的元素
我假设你的意思是你的HIDDEN输入元素a / name /
" Institution" ;.
给它一个机构的ID你是金色的
You don''t have any elements with an id of "Institution"
I assume you mean your HIDDEN input element which has a /name/ of
"Institution".
Give that an id of "Institution" and you''re golden
感谢您的帮助。我有一个后续问题。我知道如何为整个页面设置
样式,无论是在页面还是(更好)在
外部样式表中。我不想覆盖所有INPUT
元素的样式,但我似乎找不到任何修改样式的例子
一个特定的HTML页面上的元素,没有其他相同的
类型。我怎样才能做到这一点?谢谢。
Thanks for the help. I have a follow-up question. I know how to set
styles for a whole page, whether in the page or (better) in an
external style sheet. I don''t want to override the style of all INPUT
elements, but I can''t seem to find any examples of modifying the style
for one specific HTML element on a page, and nothing else of that same
type. How can I do that? Thanks.
OccasionalFlyer写道:
[snip]
OccasionalFlyer wrote:
[snip]
>
感谢您的帮助。我有一个后续问题。我知道如何为整个页面设置
样式,无论是在页面还是(更好)在
外部样式表中。我不想覆盖所有INPUT
元素的样式,但我似乎找不到任何修改样式的例子
一个特定的HTML页面上的元素,没有其他相同的
类型。我怎样才能做到这一点?谢谢。
>
Thanks for the help. I have a follow-up question. I know how to set
styles for a whole page, whether in the page or (better) in an
external style sheet. I don''t want to override the style of all INPUT
elements, but I can''t seem to find any examples of modifying the style
for one specific HTML element on a page, and nothing else of that same
type. How can I do that? Thanks.
错误的新闻组。 [后续 - 设置为
comp.infosystems。 www.authoring.stylesheets ]
但是,您可以在样式表中使用id和类选择器来限制
您的样式到特定元素。
例如
输入#机构
{
}
应该用于将样式应用于INPUT元素
id =" Institution"
Wrong newsgroup for that. [Followup-To set to
comp.infosystems.www.authoring.stylesheets]
However, you can use id and class selectors in your stylesheets to limit
your styling to specific elements.
For instance
input#Institution
{
}
should be used for applying styling to the INPUT element with
id="Institution"
这篇关于请帮助基本的onClick机制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!