IF ELSE help
Hi,
I know this is a simple question but my script does not seem to be working.
I basically want to write out a variable if it has some data if not I want to write out some others.
if(session.getVariable( "POSTCODE" ) !="")
{ out.write( "
" + session.getVariable( "POSTCODE" ) + " \n" );
}
else
{ out.write( "
" + session.getVariable( "STREET" ) + ", " + session.getVariable( "COUNTY" ) + " \n" );
}
{ out.write( "
}
else
{ out.write( "
}
Any ideas?
String comparison
Solved it, I needed to use a different comparison operator
if(session.getVariable( "POSTCODE" ).equals("-")){
out.write( "<postcode>" + session.getVariable( "STREET" ) + ", " + session.getVariable( "COUNTY" ) + "</postcode>\n" );
} else {
out.write( "<postcode>" + session.getVariable( "POSTCODE" ) + "</postcode>\n" );
}