Hi everybody,

This is not working. Let me explain it better. I have the input:

<input id="Index" name="Index" type="hidden" value="0" />

In JQuery I need to get the value of this input and use it as a
string. This is done:
$index = $('#Index');
And then I use $index.val()

But, and here is the problem, I need to incremente this value by 1 and
updated the value of the input with this new value.


On Feb 11, 6:23 pm, Ricardo Tomasi <ricardob...@gmail.com> wrote:
> Increment/decrement is for variables. You can't use it directly on a
> number. Try '3--'.
>
> Make it simple, if you use subtraction the type conversion is done for
> you:
>
> $index = $('#Index');
> val = $index.val()-1;
>
> On Feb 11, 2:37 pm, shapper <mdmo...@gmail.com> wrote:
>
> > You mean the following:
>
> >         $index = $('#Index');
> >         parseInt($index.val())--;
>
> > This still gives me the same error.
>
> > Could someone, please, tell me how to do this?
>
> > Thanks,
> > Miguel
>
> > On Feb 11, 6:38 am, Ralph Whitbeck <ralph.whitb...@gmail.com> wrote:
>
> > > Karl is right, you need to convert it from a string first.
>
> > > shapper wrote:
> > > > Hello,
>
> > > > I have an input on my page as follows:
>
> > > >   <input id="Index" name="Index" type="hidden" value="0" />
>
> > > > I am trying to increase and decrease the value of the input as
> > > > follows:
>
> > > >         $index = $('#Index');
> > > >         $index.val()--;
>
> > > > I always get an error:
> > > > invalid assignment left-hand side
>
> > > > What am I doing wrong?
>
> > > > Thanks,
> > > > Miguel

Reply via email to