/    Sign up×
Community /Pin to ProfileBookmark

Where is or what does the error mean.

In the following code:

[code=php]
<html>
<head>
<title>Enter Test</title>
<script type=”text/javascript”>
function EnterInfo(msg) {
document.getElementById(‘TA’).value += msg+”n”;
document.getElementById(‘EnterTxt’).value = ”;
}
</script>
</head>
<body>
<form onSubmit=”return false”>
Enter something here:
<br /><input id=’EnterTxt’ type=”text” value=”” onChange=”EnterInfo(this.value)” />
<br /><textarea id=”TA” rows=”10″></textarea>
</form>
</body>
</html>
[/code]

In IE, no errors, but nothing happens until I click outside the text box.
Then textbox is appended to textarea as expected.

Why does this not happen when I press ‘ENTER’ key?

In FF, it works as I designed it, but I get an error saying:

[QUOTE]

Error: [Exception… “‘Permission denied to get property XULElement.selectedIndex’ when calling method: [nsIAutoCompletePopup::selectedIndex]” nsresult: “0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)” location: “JS frame :: file:///C:/JS/New%20Folder/EnterText.html :: EnterInfo :: line 7” data: no]
Source File: file:///C:/JS/New%20Folder/EnterText.html
Line: 7

[/QUOTE]

This does not make sense to me?

Anyone have an explaination? Thanks in advance for any response.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Arty_EffemOct 28.2006 — In the following code:
[code=php]
<html>
<head>
<title>Enter Test</title>
<script type="text/javascript">
function EnterInfo(msg) {
document.getElementById('TA').value += msg+"n";
document.getElementById('EnterTxt').value = '';
}
</script>
</head>
<body>
<form onSubmit="return false">
Enter something here:
<br /><input id='EnterTxt' type="text" value="" onChange="EnterInfo(this.value)" />
<br /><textarea id="TA" rows="10"></textarea>
</body>
</html>
[/code]

In IE, no errors, but nothing happens until I click outside the text box.

Then textbox is appended to textarea as expected.


Why does this not happen when I press 'ENTER' key?

Thanks in advance for any response.[/QUOTE]
You could try closing the form, but it probably won't change anything. Do you have that page within a frameset?

Either way pressing Enter triggers a submit, at which point I would say that behaviour regarding any onchange event is unpredictable.
Copy linkTweet thisAlerts:
@JMRKERauthorOct 28.2006 — Well, you were right. Closing the form (an oversight) had no effect.

For your question ("Do you have that page within a frameset?):

1. No, it is standalone code.

or

2. Are you suggesting I should add a frameset?

When run as standalone code in FF,

I notice that the error only occurs once,

not each time I press enter. Is this significant?

Still, in IE, no error generated ...

just no actions either until I click outside box.

Should I try something other than "onChange"? Is there something else?

Just seems like such a short piece of code could drive me so crazy!!!
Copy linkTweet thisAlerts:
@JMRKERauthorOct 28.2006 — New information:

I just tried using in FF and clicking outside text box instead of 'enter'

Effect is exactly the same as IE. Passes textbox to textarea as planned.

So, the only difference now is that FF reports an error and IE does not

when the 'ENTER' key is used to submit the entry.

If there are any with other browsers, could you try script to see if errors

are generated that I would be able to decipher?

Thanks again!
Copy linkTweet thisAlerts:
@Arty_EffemOct 28.2006 — New information:

I just tried using in FF and clicking outside text box instead of 'enter'

Effect is exactly the same as IE. Passes textbox to textarea as planned.

So, the only difference now is that FF reports an error and IE does not

when the 'ENTER' key is used to submit the entry.

If there are any with other browsers, could you try script to see if errors

are generated that I would be able to decipher?

Thanks again![/QUOTE]
I dont get any message in FX (1.5.0.7) but try this function I wrote for someone on this forum recently. You can cancel the onsubmit handler.[CODE]function enterToTab(formRef)
{
/***2843294152545920454646454D***
In all text/password elements of the specifed form
Enter key 'tabs' to next visible element.
***/

for(var i=0, e=formRef.elements, len=e.length, hasNext=true; i<len && hasNext; i++)
if( /(^text$)|(password)/.test( e[ i ].type ) )
{
for(var j=i+1; j<len && (/hidden/.test(e[j].type)||!/(^text)|(password)/.test(e[j].type)); j++)
;
hasNext = j!=len;

e[ i ].onkeypress=new Function("var k=(arguments[0]?arguments[0].which:window.event.keyCode )!=13;
if(!k && "+hasNext+")this.form.elements["+(j)+"].focus(); return k;");
}

}[/CODE]
Call it after the form loads and pass it a [I]reference[/I] to the form, e.g.:[CODE]enterToTab(document.forms[0]);[/CODE]
Copy linkTweet thisAlerts:
@JMRKERauthorOct 28.2006 — After some more searching, I found the following statement:
onchange = script [CT]

The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus. This attribute applies to the following elements: INPUT, SELECT, and TEXTAREA.[/QUOTE]

This would explain the actions of both IE and FF. It is doing exactly what it

is supposed to do when you move off the input (textbox) entry.

It may also explain the error in FF as it mentions something about 'selected'

whenever the error occurs. IE seems to ignore this for some reason.

I'll continue to investigate ...

Does anyone know how to fool the FF into thinking something has a selectedIndex when the enter key is pressed over an input (textbox) field?

NOTE to 'Arty Effem': I just saw you posting while writing this post.


I'll get back after I try your suggestion out.
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...