New to Javascript and trying to solve a problem

G

Guy Noir

Hello all. I am new to Javascript but versed in JAva, c#, etc.

I'm running into a problem and I'm hoping someone can point me in the
right direction.

I have 2 images (Up and down arrows) and I'm trying to change the value
of a text box based on if the up or down arrow was pressed. (Spinner
box).

I am getting an error and I'm not quite sure how to go about debugging.
(Can someone suggest aan easy to use debugger?)

The error is: Error: getDOMObject is not defined. I assume the problem
is with one of these 2 lines, and I suspect it's the "State" line:

var obUpDownControl1= getDOMObject("__UpDownControl1_Input");
var ob___UpDownControl1_State=
getDOMObject("__UpDownControl1_State");

Here are the HTML form attributes:

<input type="text" id="__UpDownControl1_Input"
name="__UpDownControl1_Input" height="30px" value="2" />

<img title="Increment value" src="images/UpArrow_10x10.gif"
onclick="javascript:eek:nUpArrowClick_UpDownControl1();"
style="border-width:0;" />

<img title="Decrement value" src="images/DownArrow_10x10.gif"
onclick="javascript:eek:nDownArrowClick_UpDownControl1();"
style="border-width:0;" />

And here is the associated javascript:

<script language="javascript">
var obUpDownControl1= getDOMObject("__UpDownControl1_Input");
var ob___UpDownControl1_State=
getDOMObject("__UpDownControl1_State");
var UpDownControl1_MaxVal = 10;
var UpDownControl1_MinVal = 0;
var UpDownControl1_IncVal = 1;
var iobUpDownControl1Val=obUpDownControl1.value;
function onUpArrowClick_UpDownControl1()
{
if (((iobUpDownControl1Val-0) + (UpDownControl1_IncVal+0))<=
UpDownControl1_MaxVal)
{
obUpDownControl1.value =(iobUpDownControl1Val-0) +
(UpDownControl1_IncVal+0);
iobUpDownControl1Val=obUpDownControl1.value;
ob___UpDownControl1_State.value = obUpDownControl1.value;
}
}

function onDownArrowClick_UpDownControl1()
{
if (((iobUpDownControl1Val-0)-(UpDownControl1_IncVal-0))>=
UpDownControl1_MinVal)
{
obUpDownControl1.value
=(iobUpDownControl1Val-0)-(UpDownControl1_IncVal-0);
ob___UpDownControl1_State.value = obUpDownControl1.value;
iobUpDownControl1Val=obUpDownControl1.value;
}
}

function getControlValue_UpDownControl1(strVal)
{
var iVal = __UpDownControl1_Input.value;
return parseInt(iVal, 10);
}
</script>

Any help or if you could point me in the right direction would be most
excellent.

TIA
-Guy
 
W

web.dev

Guy said:
The error is: Error: getDOMObject is not defined. I assume the problem
is with one of these 2 lines, and I suspect it's the "State" line:

var obUpDownControl1= getDOMObject("__UpDownControl1_Input");
var ob___UpDownControl1_State=
getDOMObject("__UpDownControl1_State");

Here are the HTML form attributes:

<input type="text" id="__UpDownControl1_Input"
name="__UpDownControl1_Input" height="30px" value="2" />

<img title="Increment value" src="images/UpArrow_10x10.gif"
onclick="javascript:eek:nUpArrowClick_UpDownControl1();"
style="border-width:0;" />

<img title="Decrement value" src="images/DownArrow_10x10.gif"
onclick="javascript:eek:nDownArrowClick_UpDownControl1();"
style="border-width:0;" />

The use of the javascript pseudo-protocol is unnecessary and may do
more harm than good.
<script language="javascript">

The language attribute is deprecated. Use the type attribute instead:

var obUpDownControl1= getDOMObject("__UpDownControl1_Input");

The error message you have is actually pretty helpful. From the script
that you have given, I do not see a method called getDOMObject()
declared anywhere. Define this method and all should be well. Or
perhaps you meant the getElementById() method instead?
 
G

Guy Noir

web.dev said:
The use of the javascript pseudo-protocol is unnecessary and may do
more harm than good.


The language attribute is deprecated. Use the type attribute instead:

<script type = "text/javascript">

Thanks for the tip.
The error message you have is actually pretty helpful. From the script
that you have given, I do not see a method called getDOMObject()
declared anywhere. Define this method and all should be well. Or
perhaps you meant the getElementById() method instead?

OK. I see what happened here. What is TRYING to be accomplished (And
again this may be "the old way") is that we are trying to get and set
the value of a text box on this form.

I see now that document.getElementById() is working for me. Thanks so
much for the feedback and I did learn something here!
-Guy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top