PDA

View Full Version : ASP IF statement and For Loop


flyclassic
09-23-2002, 05:37 AM
Hello, in ASP how do i use a IF statement and a for loop? Any Examples
I would like to convert from Javascript to ASP, but in ASP i don't know how to use for command and if, it's different from Javascript and C language

for(i=0;i<objNodeList.length;i++)
{
objNode=objNodeList.item(i);

if(objNode.nodeType ==7)
{
objNewPI = objDOM.createProcessingInstruction("YourApp"," ");
objNewPI.data = objNode.data
objNode.parentNode.replaceChild(objNewPI, objNode);
alert("New Processing Instruction created");
}
}

glenngv
09-23-2002, 06:13 AM
<%
for i = 0 to 9
response.write "<p>" & i
if i=0 then
response.write "This is the first loop<br>"
elseif i=9 then
response.write "This is the last loop<br>"
end if
next
%>

flyclassic
09-23-2002, 08:54 AM
thanksSssssssss!

Alekz
09-23-2002, 09:37 AM
Hi,
Try placing <%@language="JScript"%> on top of Your ASP page (if i remeber well the directive) and just paste Your JavaScript instead of translating it to VBScript...

Alex

flyclassic
09-24-2002, 03:33 AM
hi, is this correct from my javascript to vb asp conversion?
I suppose so.. anyone tell me?


for i = 0 to objNodeList.length

objNode=objNodeList.item(i)

if objNode.nodeType == 7

objNewPI = objDOM.createProcessingInstruction("YourApp"," ");
objNewPI.data = objNode.data
objNode.parentNode.replaceChild(objNewPI, objNode);

end if
next

glenngv
09-24-2002, 03:47 AM
you still didn't follow the syntax I showed.
anyway, here's a link about using XML in ASP
http://www.asp101.com/articles/michael/htmlxml/