Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > New to Javascript and trying to solve a problem

Reply
Thread Tools

New to Javascript and trying to solve a problem

 
 
Guy Noir
Guest
Posts: n/a
 
      10-23-2006
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="javascriptnUpArrowClick_UpDownControl1( );"
style="border-width:0;" />

<img title="Decrement value" src="images/DownArrow_10x10.gif"
onclick="javascriptnDownArrowClick_UpDownControl 1();"
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

 
Reply With Quote
 
 
 
 
web.dev
Guest
Posts: n/a
 
      10-23-2006

Guy Noir wrote:
> 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="javascriptnUpArrowClick_UpDownControl1( );"
> style="border-width:0;" />
>
> <img title="Decrement value" src="images/DownArrow_10x10.gif"
> onclick="javascriptnDownArrowClick_UpDownControl 1();"
> 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:

<script type = "text/javascript">

> 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?

 
Reply With Quote
 
 
 
 
Guy Noir
Guest
Posts: n/a
 
      10-24-2006
web.dev wrote:
> Guy Noir wrote:
> > 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="javascriptnUpArrowClick_UpDownControl1( );"
> > style="border-width:0;" />
> >
> > <img title="Decrement value" src="images/DownArrow_10x10.gif"
> > onclick="javascriptnDownArrowClick_UpDownControl 1();"
> > 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:
>
> <script type = "text/javascript">


Thanks for the tip.

>
> > 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?


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript help needed to solve problem in create input text filedcontinuously? Amit Prakash Pawar Javascript 0 09-08-2009 04:14 PM
problem I am trying to solve Gorge Lucas ASP .Net 4 05-04-2009 12:30 PM
Trying to solve a python/mechanize "error 500" http error bruce Python 0 07-21-2008 08:19 PM
Trying to solve a python/mechanize "error 500" http error bruce Python 0 07-21-2008 08:18 PM
Why problem is Spring Framework trying to solve? James Yong Java 2 10-03-2005 05:31 PM



Advertisments