需要帮助的东西 [英] need help with something

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

问题描述

我是一名大学生,我在使用我的一项
作业时遇到了麻烦。我们在javascript中创建一个拼写检查器,必须将用户提交的单词(使用表单)与5字词词典进行比较。如果

这个单词拼写正确,我们所要做的就是这么说。如果没有,我们

必须根据单词的单个

字母从词典中推荐一个单词,或者询问用户是否要将单词添加到

字典,只要

浏览器保持打开状态就会将字典增加到6个字。


我不是要求任何人告诉我该怎么做,我也不会要求b $ b任何人为我做这件事。我只想问一下,到目前为止,有人能看看我有什么,并告诉我,我做错了什么。因为我刚刚开始为我工作,所以我很长的时间



我的javascript能力非常有限,作为先决条件,这个人的b $ b是一个玩笑。


这是我到目前为止所拥有的。我想要做的就是在第一个文本框中输入

用户类型的单词,当他们按下提交按钮时,

它会显示在第二个文本框中文本框:


< script type =" text / javascript">


function usersubmit(form){

var x = document.submitform.userentry.value;

document.userWord.userWordResult.value = x;

}

- >

< / script>

< / head>

< body>


< form name = submitform onsubmit =" return checkform(this);">

< input type = text name = userentry>

< input type = submit value ="提交" >

< / form>


< form name = userWord onsubmit =" return usersubmit(this);">

< input type = text name = userWordResult>

< / form>

I''m a college student, and I''m having trouble with one of my
assignments. We creating a spell checker in javascript that has to
compare a user submitted word (using forms) to a 5 word dictionary. If
the word is spelled correctly, all we have to do is say so. If not, we
have to suggest a word from the dictionary based on the individual
letters of the word, or ask if the user wants to add the word to the
dictionary, which would incrememnt the dictionary to 6 words as long as
the browser remains open.

I''m not asking for anyone to tell me how to do this, nor am I asking
anyone to do it for me. I''m simply asking if someone could look at
what I have so far and tell me what I''m doing wrong. I''m a long way
from being done, as I''ve just started getting stuff to work for me.
I''m very limited in my javascript ability, as the pre-requisite class
for this one was a joke.

Here''s what I have so far. What I''m trying to do is take the word the
user types in the first text box and when they press the submit button,
it shows up in the second text box:

<script type="text/javascript">

function usersubmit (form){
var x = document.submitform.userentry.value;
document.userWord.userWordResult.value = x;
}
-->
</script>
</head>
<body>

<form name=submitform onsubmit="return checkform(this);">
<input type=text name=userentry>
<input type=submit value="Submit" >
</form>

<form name=userWord onsubmit="return usersubmit(this);">
<input type=text name=userWordResult>
</form>

推荐答案




表单上的事件处理程序onsubmitsubmitform应该有

..value assigmening功能,并且应该在

返回/提交表格进行处理之前完成:


功能checkform(表格){

........

var x = document.submitform.userentry.value;

文件。 userWord.userWordResult.value = x;

form.submit();

}


Dann


The event handler onsubmit on form "submitform" should have the
..value assigmening function and should do it before
returning/submitting the form for processing:

function checkform(form) {
........
var x = document.submitform.userentry.value;
document.userWord.userWordResult.value = x;
form.submit();
}

Dann


感谢您的帮助。我能够正常工作,现在我正在努力将用户提交的单词与我创建的数组进行比较。这个

代码,虽然我知道它还没有完全存在,一直给我一个表格

没有属性错误:


< script type =" text / javascript">

<! -

function readText (表格){

var wordList = new Array(他们的,日历,墓地,

推荐,相信) );

i = form.inputbox.value;

var wordUsed = form.inputbox.value;

/ * var wordSplit = wordUsed.split ("); * /

form.userWordResult.value ="" ;;


if(wordList [i] == wordUsed)

form.userWordResult.value ="正确;

}


- >

< / script>

< / head>

< body onLoad =" readText()">

< form name =" myform" method =" GET">

输入您的字词:< br />

< input type =" text" name =" inputbox">

< input type =" button"名称= QUOT; BUTTON2" Value =" Check Spelling"

onClick =" readText(this.form)">

< p>你的话是:< / p>

< input type =" text" name =" userWordResult"

onClick =" writeText(this.form)">

< / form>

Any想法?

Thanks for the help. I was able to get that working, now I''m trying to
compare the word submitted by the user to the Array I created. This
code, while I know it''s not quite there yet, keeps giving me a "Form
has no properties" error:

<script type="text/javascript">
<!--
function readText (form) {
var wordList = new Array("their", "calendar", "cemetery",
"recommend", "believe");
i = form.inputbox.value;
var wordUsed = form.inputbox.value;
/*var wordSplit = wordUsed.split("");*/
form.userWordResult.value = "";

if(wordList[i] == wordUsed)
form.userWordResult.value = "Correct";
}

-->
</script>
</head>
<body onLoad="readText()">
<form name="myform" method="GET">
Enter your word: <br />
<input type="text" name="inputbox">
<input type="button" name="button2" Value="Check Spelling"
onClick="readText(this.form)">
<p>Your word is:</p>
<input type="text" name="userWordResult"
onClick="writeText(this.form)">
</form>
Any ideas?



AT ***** @ gmail.com 写道:

您的表格被称为myform,而不是表格


//在这里添加:


var form = document.forms [''myform''];


//其余的原样。我不同意syntacs,但是它使得

技巧:

AT*****@gmail.com wrote:
Your form is called "myform", not "form"

// Add here:

var form = document.forms[''myform''];

// the rest as it is. I don''t agree with the syntacs, but it makes the
trick:
i = form.inputbox.value;
var wordUsed = form.inputbox .value;
/ * var wordSplit = wordUsed.split(""); * /
form.userWordResult.value ="" ;;

if(wordList [i] == wordUsed)
form.userWordResult.value =" Correct";
i = form.inputbox.value;
var wordUsed = form.inputbox.value;
/*var wordSplit = wordUsed.split("");*/
form.userWordResult.value = "";

if(wordList[i] == wordUsed)
form.userWordResult.value = "Correct";






这篇关于需要帮助的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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