Forum Moderators: open

Message Too Old, No Replies

JavaScript

         

jozeph

2:36 pm on May 4, 2004 (gmt 0)

10+ Year Member



Hello. I'm having some very buggy behavior with Javascript and need some assistance in figuring it out. It seems as though somewhere along in my code I've messed with the way javascript is resolving objects in my code.

For instance this simple chunck of code will work fine, returning [ object ] in the msg box.
<INPUT
class=AppinputTextEditable id=txtJury
style="WIDTH: 30px" tabIndex=12 type=text maxLength=2 value=0 name=txtJury onchange="alert(this)" >

This will work fine, returning the value set in a message box.

<INPUT
class=AppinputTextEditable id=txtJury
style="WIDTH: 30px" tabIndex=12 type=text maxLength=2 value=0 name=txtJury onchange="alert(this.value);">

However with this chunch of code I get a runtime error, object expected.

<INPUT class=AppinputTextEditable id=txtJury style="WIDTH: 30px" tabIndex=12 type=text maxLength=2 value=0 name=txtJury onchange="calcDaysOff(this);" >

<Script>
function CalcDaysOff(obj){if (/([\D])+)¦^/x.test(obj.value)){
document.activeElement.setAttribute("value",0);
}</script>

I'm also having similar parameter passing issues... Please advise.

jozeph

2:56 pm on May 4, 2004 (gmt 0)

10+ Year Member



Note... I copy pasted wrong.. I did have my {} correct like this for my script.

<Script>
function CalcDaysOff(obj){

if (/([\D])+)¦^/x.test(obj.value)){
document.activeElement.setAttribute("value",0);
}
}</script>

Bernard Marx

7:23 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jozeph,

I'm getting an error from the regExp in the condition:

[red]expected '/'[/red]

With next to nil reg exp knowledge, I can't sort that out.
However, your 'object expected' error probably comes from this:

[blue]onchange="calcDaysOff(this);"[/blue]

mixed with
[blue]function CalcDaysOff[/blue]

...the capitalization being the thing.