表单变量未设置 [英] form variable not being set

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

问题描述

我已经写了一些javascript代码,我认为应该根据用户点击的内容将某个表单设置为某个值。

不幸的是,它不起作用。这里是网址:

http ://www.frostjedi.com/terra/scripts/graemlin3.html


点击颜色调色板,然后点击提交按钮

显示名为color的表单变量未设置。如果你看看这个javascript源代码,那么你会看到我至少试图使用document.forms [0] .color来设置它。 .value ='''xxxxxx''" ...


关于我做错了什么以及如何修复它的任何想法

将不胜感激 - 谢谢!

i''ve written some javascript code that i believe should set a form
variable to a certain value, depending on what the user clicks on.
unfortunately, it isn''t working. here''s the url:

http://www.frostjedi.com/terra/scripts/graemlin3.html

clicking in the color palette thing and then clicking the submit button
reveals that the form variable named color isn''t being set. if you
look at the javascript source, you''ll see that i''m atleast attempting
to set it with "document.forms[0].color.value = ''xxxxxx''"...

any ideas on what i''m doing wrong and how i could go about fixing it
would be appreciated - thanks!

推荐答案

警报的工作,我会说。


" yawnmoth" < TE ******* @ yahoo.com>在消息中写道

news:11 ********************** @ l41g2000cwc.googlegr oups.com ...
A job for ''alert'', I''d say.

"yawnmoth" <te*******@yahoo.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
我已经写了一些javascript代码,我认为应该根据用户点击的内容将表格变量设置为某个值。不幸的是,它不起作用。这里是网址:

http ://www.frostjedi.com/terra/scripts/graemlin3.html

单击调色板中的内容然后单击提交按钮
显示表单变量已命名颜色没有设定。如果你看看javascript源码,你会看到我至少试图用document.forms [0] .color.value =''xxxxxx''来设置它。 ...

关于我做错了什么以及如何解决它的任何想法将非常感谢 - 谢谢!
i''ve written some javascript code that i believe should set a form
variable to a certain value, depending on what the user clicks on.
unfortunately, it isn''t working. here''s the url:

http://www.frostjedi.com/terra/scripts/graemlin3.html

clicking in the color palette thing and then clicking the submit button
reveals that the form variable named color isn''t being set. if you
look at the javascript source, you''ll see that i''m atleast attempting
to set it with "document.forms[0].color.value = ''xxxxxx''"...

any ideas on what i''m doing wrong and how i could go about fixing it
would be appreciated - thanks!



在文章< 11 ********************** @ l41g2000cwc.googlegroups .com> ;,

yawnmoth < TE ******* @ yahoo.com>写道:
In article <11**********************@l41g2000cwc.googlegroups .com>,
"yawnmoth" <te*******@yahoo.com> wrote:
点击调色板的东西,然后点击提交按钮
显示名为color的表单变量未被设置。如果你看看javascript源码,你会看到我至少试图用document.forms [0] .color.value =''xxxxxx''来设置它。 ...
clicking in the color palette thing and then clicking the submit button
reveals that the form variable named color isn''t being set. if you
look at the javascript source, you''ll see that i''m atleast attempting
to set it with "document.forms[0].color.value = ''xxxxxx''"...




将其修剪为颜色窗格和javascript。


实现自己的调试控制台所以你可以打印出进度数据。

见:
http://groups-beta.google.com/group/...t/msg/170ddb0d ...

是一个如何使用输入字段的示例。


Robert


<!DOCTYPE HTML PUBLIC" - // W3C / / DTD HTML 4.01 Transitional // EN"

" http://www.w3.org/TR/html4/loose.dtd">

< html> ;

< head>

< title>简单验证< / title>


< script type =" text / javascript">


函数myfunct ion(formName,formField)

{


var ok;

var newValue = document.forms [formName] .elements [ formField] .value;

alert(''formName =''+ formName +

''formField =''+ formField +

' 'value =''+ newValue);


if(/ ^(0 | [1-9] \d *)



Trim this down to just the color pane and the javascript.

Implement you own debug console so you can print out progress data.
see:
http://groups-beta.google.com/group/...t/msg/170ddb0d...
Here is an example of how to work with an input field.

Robert

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Simple validate</title>

<script type="text/javascript">

function myfunction(formName,formField)
{

var ok;
var newValue = document.forms[formName].elements[formField].value;
alert(''formName = '' + formName +
'' formField = '' + formField +
'' value = '' + newValue);

if( /^(0|[1-9]\d*)


/ .test(newValue))

{

var theValue = parseInt(newValue,10)+ 1;

document.forms [formName]。 elements [formField] .value = theValue;

ok = true;

}

else

{ok = false;

alert(''你需要输入一个数字。'')

}


返回ok;

}

< / script>

< / head>

< body>

< p>

HTML文件演示了如何增加输入字段。

请输入一个数字。 < / p>

< p>

< / p>

< form name =" myForm"

action =" http://www.natAValidWebAddress.com"

method =" POST"

onsubmit =" return myfunction('' myForm'',''theAddress'');">


< p>地址:& nbsp;

< input type = "文本"名称= QUOT; theAddress" id =''theAddress''size =" 40">< / p>

< br>

< input type =" submit" value ="提交地址信息"

< / form>

< / body>

< / html>
/.test(newValue) )
{
var theValue = parseInt(newValue,10) + 1;
document.forms[formName].elements[formField].value = theValue;
ok = true;
}
else
{ ok = false;
alert(''You need to enter a number.'')
}

return ok;
}
</script>
</head>
<body>
<p>
The HTML file demonstrates how increment an input field.
Please input a number. </p>
<p>
</p>
<form name="myForm"
action="http://www.natAValidWebAddress.com"
method="POST"
onsubmit="return myfunction(''myForm'',''theAddress'');">

<p>Address:&nbsp;
<input type="text" name="theAddress" id=''theAddress'' size="40"></p>
<br>
<input type="submit" value="Submit address information">
</form>
</body>
</html>


这篇关于表单变量未设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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