![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
My purpose on storing each radio name and value into an array is for me to set the cookie easier (I think). My idea is: I got a form with different radio button groups. After the user check the radio values, I will store names and values into a 2D array. For example: the user check "outlook, start" and "word, completed", I will put it into status[0][0]=outlook, status[0][1]=start,... Then, I can put them into cookie like: Use a for..loop and setCookie( status[name], status[value]); And later on, I can get the data in the cookie and display on the form again. |
#2
| |||
| |||
|
|
status[0] = new Pair('outlook', 'start'); snip |
#3
| |||
| |||
|
|
Michael Winter wrote: snip status[0] = new Pair('outlook', 'start'); snip As an observation in passing, the global variable identifier - status - corresponds with the - status - property of the window object. As - window.status - is one of those properties with an overloaded setter assigning an Array to the property might just have the Array type-converted to a string and the result displayed in the window's status bar. And attempts to read the property might be returning a string primitive, subsequently type-converted to a String object when used with bracket notation property accessors, allowing assignment to properties of that (transient) String object, and reading (undefined) values from it, without error but to no effect. It might be that the global - var - declaration would avoid the problem in some browsers, but not according to ECMA 262, where section 10.1.3 reads "If there is already a property of the Variable object with the name of a declared variable, the value of the property and its attributes are not changed.", in the context of variable instantiation. (The global object is used as the "Variable" object in global execution contexts.) |

#4
| |||
| |||
|
|
So in other (shorter) words, use a name such as 'state' to avoid any conflict. ![]() snip |
#5
| |||
| |||
|
|
Michael Winter wrote: snip So in other (shorter) words, use a name such as 'state' to avoid any conflict. ![]() snip Yes, or keep the variable out of the global scope. Richard. |
#6
| |||
| |||
|
|
On Wed, 4 Aug 2004 14:11:59 +0100, Richard Cornford Richard (AT) litotes (DOT) demon.co.uk> wrote: Michael Winter wrote: snip status[0] = new Pair('outlook', 'start'); snip As an observation in passing, the global variable identifier - status - corresponds with the - status - property of the window object. As - window.status - is one of those properties with an overloaded setter assigning an Array to the property might just have the Array type-converted to a string and the result displayed in the window's status bar. And attempts to read the property might be returning a string primitive, subsequently type-converted to a String object when used with bracket notation property accessors, allowing assignment to properties of that (transient) String object, and reading (undefined) values from it, without error but to no effect. It might be that the global - var - declaration would avoid the problem in some browsers, but not according to ECMA 262, where section 10.1.3 reads "If there is already a property of the Variable object with the name of a declared variable, the value of the property and its attributes are not changed.", in the context of variable instantiation. (The global object is used as the "Variable" object in global execution contexts.) So in other (shorter) words, use a name such as 'state' to avoid any conflict. ![]() Yet another thing I've overlooked today. |
#7
| |||||
| |||||
|
|
My previous problem, it seems is solved. I figured out another way to get values from Radio button and set cookie last night. May be it is a stupid way. But, it works. |
|
Now, I got another problem. I haven't figure out how can I set the values in the cookies back to radio form using getCookie() method. |
|
[...] THANKS IN ADVANCE. |
|
My new code is as follow: body script language="javascript" |
|
[...] [Top post] |
#8
| |||
| |||
|
|
Even though javascript isn't a typed language like vb script/c++ I find it usefull to put type infront of the variable names [...] iStatus // an integer fStatus // a float |
#9
| |||
| |||
|
|
Harag wrote: Even though javascript isn't a typed language like vb script/c++ I find it usefull to put type infront of the variable names [...] iStatus // an integer fStatus // a float There are no real integers in ECMAScript implementations, all numbers are floats (read the FAQ, ask Google). I use the prefix "i" only if I expect the fractional part to be zero. For the other numbers I use "n" as prefix. Full ACK to the rest of prefixes, I tend to use the same style. |
![]() |
| Thread Tools | |
| Display Modes | |
| |