Closed Thread Icon

Topic awaiting preservation: accessing local variable..pls help Pages that link to <a href="https://ozoneasylum.com/backlink?for=12943" title="Pages that link to Topic awaiting preservation: accessing local variable..pls help" rel="nofollow" >Topic awaiting preservation: accessing local variable..pls help\

 
Author Thread
Pimms One
Bipolar (III) Inmate

From: Australia
Insane since: Jun 2003

posted posted 10-21-2003 07:45

I have the following code, can you please help me to figure out how I could access the f_seat_status variable outside the if loop? Thank you.

<%

int l_session_seats_available =3;

if (l_session_seats_available > 0) {
String f_seat_status = "enrolled";
} else if (l_session_seats_available <= 0) {
String f_seat_status = "waiting list";
}
%>

<%=f_seat_status %> <--- How do I get the f_seat_status outside the IF loop??

Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 10-21-2003 08:35

Hmm...in PHP you would have to give the variable a global scope for it to be available higher up in the heirarchy. That's what you need ot do here, I think, but i don't know the exact function for it

Rhino
Bipolar (III) Inmate

From: New Jersey, USA
Insane since: Jul 2003

posted posted 10-21-2003 08:45

Change where you declare it. I moved it outside the conditional statement right under the declaration of the integer. This will change the scope and allow you to see it.

<%

int l_session_seats_available =3;
String f_seat_status = "";

if (l_session_seats_available > 0) {
f_seat_status = "enrolled";
} else if (l_session_seats_available <= 0) {
f_seat_status = "waiting list";
}
%>


Skaarjj
Maniac (V) Mad Scientist

From: :morF
Insane since: May 2000

posted posted 10-21-2003 08:48

well, yes...I suppose that one would work too

Pimms One
Bipolar (III) Inmate

From: Australia
Insane since: Jun 2003

posted posted 10-23-2003 02:55

Thank you so much for teaching me. Thanks again.


« BackwardsOnwards »

Show Forum Drop Down Menu