Click to See Complete Forum and Search --> : Syntax problem


paolodina
07-16-2003, 10:04 AM
Hi guys, i'm a newbie in javascript, so, this could be a silly question, anyway..

I have a text field that can accept an integer (in the environment which i actually use, Zope, this might be specified inserting the string :int after the field name)

<input type="text" name="resPerPage:int" />

Now i want increment and decrement the value of resPerPage using two buttons..

<input type="button" value="+" onClick="javascript:this.form.resPerPage:int.value++;" />
<input type="button" value="-" onClick="javascript:this.form.resPerPage:int.value--;" />

But internet explorer display this error: character 21 expected ;

Character 21 is the second :

Is there a way to handle this case?
IMHO javascript(or better, the form i have used) can't handle the ':int' part.

Thanks guys, hope someone help!

Paolo Dina

Khalid Ali
07-16-2003, 10:17 AM
I am not aware of the this construct in HTML
<input type="text" name="resPerPage:int" />

though you may be able to do something like this...

(parseInt(this.form.resPerPage.value)++

paolodina
07-16-2003, 10:30 AM
Thanks Khalid for your reply.

I think that the problem is slightly different.

The name of variable is entirely 'resPerPage:int' (without quotes), not only 'resPerPage'.

Thus, this will not work:
this.form.resPerPage.value++

This should:
this.form.resPerPage:int.value

but it seems that Javascript not accept the colon (:) character in string, so i guess there would be a sort of method to quote "strange" characters!

Dunno.. :)

Paolo Dina

SlankenOgen
07-16-2003, 10:56 AM
Try

this.form[resPerPage:int].value

paolodina
07-16-2003, 11:20 AM
wow, this works fine!

form['resPerPage:int'].value++

Many thanks!
Paolo