使用Javascript设置表单 [英] Setting forms using Javascript
问题描述
大家好,
学习Javascript(通过谷歌)创建具有预设值的表格。
如下所示。我发现的问题是:我似乎无法弄清楚
(或通过谷歌找到目前为止)如何在输入类型时预设表格选项
是单选按钮或下拉列表。使用输入字段时,同样的方法似乎不起作用
。
任何人都知道这么全面的网站吗?
非常感谢,
Daniel
< FORM name =" PersProf"行动= QUOT; newuser.pl" method =" POST">
< table border =" 0">
< tr>
< td WIDTH =" 200">
名字
< / td>
< td>
< input type =" text"名称= QUOT;如first_name" maxlength = 32 size = 32>
< / td>
< / tr>
< / table>
< script language =" JavaScript">
<! -
//设置值:
document.PersProf.first_name.value =''$ first_name'';
- >
< / script>
Hi All,
Been learning Javascript (via google) to create forms with pre-set values.
As seen below. My problem I have found is this: I can''t seem to figure out
(or find so far via google) how to preset form options when the input type
is a radio button, or dropdown list. The same method does not seem to work
with input fields.
Anyone know of such a comprehensive site?
Thanks ahead,
Daniel
<FORM name="PersProf" action="newuser.pl" method="POST">
<table border="0">
<tr>
<td WIDTH="200">
First Name
</td>
<td>
<input type="text" name="first_name" maxlength=32 size = 32>
</td>
</tr>
</table>
<script language="JavaScript">
<!--
//setting the value:
document.PersProf.first_name.value = ''$first_name'';
-->
</script>
推荐答案
first_name'';
- >
< / script>
first_name'';
-->
</script>
daniel kaplan写道:
daniel kaplan wrote:
我发现的问题是:我似乎无法弄明白
(或通过谷歌找到目前为止)如何预设表格输入类型
是单选按钮或下拉列表时的选项。使用输入字段时,相同的方法似乎不起作用。
My problem I have found is this: I can''t seem to figure out
(or find so far via google) how to preset form options when the input type
is a radio button, or dropdown list. The same method does not seem to work
with input fields.
您的意思是预先选择:
< input type = "无线电"检查>和
<选择选择值=" val">文字< /选项>
Do you mean preselected:
<input type="radio" checked> and
<option selected value="val">text</option>
2004年12月11日星期六09:45 :59 -0500,daniel kaplan< no **** @ nospam.com>
写道:
On Sat, 11 Dec 2004 09:45:59 -0500, daniel kaplan <no****@nospam.com>
wrote:
大家好,
你没有用Javascript指定初始值。您可以用HTML指定它们:
< input type =" text" ... value =" initial value"
< input type =" checkbox" ...已检查>
< input type =" radio" ...已检查>
< select ...>
< option ... selected> ...< / option>
< / select>
< textarea ...>初始值< / textarea>
我建议你阅读HTML规范
(< URL:http://www.w3.org/TR/html4/>),而不是依赖网络。
有关表格的信息,请参阅第17节
(< URL:http://www.w3.org/TR/html4/interact/forms.html>)。
如果您有任何其他问题,请在alt.html或
comp.infosystems中询问。 www.authoring.html 。
[snip]
< script language =" ; JavaScript的">
语言属性已被弃用超过六年。请改为使用
类型属性:
< script type =" text / javascript">
<! -
使用SGML注释分隔符隐藏脚本是一种过时的做法。它不是必需的
。
//设置值:
document.PersProf.first_name.value =''
Hi All,
Been learning Javascript (via google) to create forms
with pre-set values.
You don''t specify initial values with Javascript. You specify them in HTML:
<input type="text" ... value="initial value">
<input type="checkbox" ... checked>
<input type="radio" ... checked>
<select ...>
<option ... selected>...</option>
</select>
<textarea ...>initial value</textarea>
I suggest you read the HTML Specification
(<URL:http://www.w3.org/TR/html4/>), rather than rely on the Web.
Information regarding forms can be found under section 17
(<URL:http://www.w3.org/TR/html4/interact/forms.html>).
If you have any further problems, please ask in alt.html or
comp.infosystems.www.authoring.html.
[snip]
<script language="JavaScript">
The language attribute has been deprecated for over six years. Use the
type attribute instead:
<script type="text/javascript">
<!--
Hiding scripts with SGML comment delimiters is an obsolete practice. It''s
not necessary.
//setting the value:
document.PersProf.first_name.value = ''
>
这篇关于使用Javascript设置表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!