if statement
20 Dec 2008 00:27:59 GMT
22 Dec 2008 00:39:05 GMT
22 Dec 2008 00:39:05 GMT
when you using JAVA
make sure you check you string by using "String.equals(...)" not "=="
I found a problem in your code
if (type == "1")
when you using JAVA
make sure you check you string by using "String.equals(...)" not "=="
22 Dec 2008 19:12:49 GMT
22 Dec 2008 19:12:49 GMT
Great, thank you very much.
ZK - Open Source Ajax Java Framework
I think this is sad, but... I'm at a loss...
I am trying to do an if statement in a function and it's just not working.
I have a test.zul file and a test.zs file. in the zul file, I have this... <zscript src="test.zs" />
Ultimately what I want, is to have some variables that i want to change depending on what's selected in a listbox.
Then what's done in the function will vary depending on what the variable is.
But the if statement just isn't working.
some example code...
test.zul
<variables type="1" /> <zscript src="test.zs" /> <listbox id="LBtest" mold="select" rows="1"> <listitem label="first" value="1"/> <listitem label="second" value="2"/> <listitem label="third" value="3"/> <attribute name="onSelect"> self.setVariable("type", LBtest.getSelectedItem().getValue(), true); </attribute> </listbox> <button label="submit" onClick="submit()"/>test.zul
void submit() { if (type == "1"){ alert("1"); } if (type == "2"){ alert("2"); } if (type == "3"){ alert("3"); } if (type != null){ alert("null... type == "+type); } }In the if statement, I have tried using single quotes, no quotes, and even assigning other variables with the values, and then referencing the various variables...
Ex:
self.setVariable("varA", 1, true); if (Qtype == varA){ alert("1"); }I get a message saying "null... type == 1" (or 2 or 3, if that's what i have selected)
If I say ...
if (type != "3"){
(doing this with all of them, no quotes, single quotes and double quotes) then I get an alert.
I dont know how to reference these... the variable registers as no being null... but what is it?
Or my real question... how do check the variable against something...
How do I check to see if the variable type is equal to 1, 2 or 3 so that i can know what to do in my function?
Any and all help is greatly appreciated... Sorry for the long intro here, but I don't know how else to clearly ask my question...
thanks.