PDA

View Full Version : != if statement


crmpicco
06-14-2005, 09:14 AM
I have this JS:



records="<%=count_a%>"
alert (records);

if var(records) !=0
{
document.all.tt.innerHTML=str;
}


How do i only do document.all.tt.innerHTML=str; when records = 0?

martin_narg
06-14-2005, 09:20 AM
var records="<%=count_a%>";

if( records == 0 ) {
document.getElementById("tt").innerHTML = str;
}



Please note I've used
document.getElementById("myElementId")
to get the HTML element (like a div, a, p, span, etc tag). If you are referencing a form element (input, textarea, etc) then you can use
document.myFormName.myFormElementName
setting its value with
document.myFormName.myFormElementName.value

Hope this helps

m_n

_Aerospace_Eng_
06-14-2005, 09:22 AM
dang beat me to it martin
Wait where is str being defined?

glenngv
06-14-2005, 09:30 AM
You can also do it like this:
<%
if count_a <> 0 then
%>
document.getElementById("tt").innerHTML=str;
<%
}
%>
Outputting the js code only when it is needed.