jbsmith Posted September 9, 2009 Share Posted September 9, 2009 Not sure if this should be in the ASP forum or this one (probably could go either), so here goes. I don't know hardly any - probably best to say dont know any at all - javascript. However I have a need to convert some code from asp to js.the code is checking to see if certain variables are null and if so counting how many of those variables are as such.the ASP looks like this: <%Dim countercounter = 0if a <> "" then classcounter = classcounter + 1if b <> "" then classcounter = classcounter + 1if c <> "" then classcounter = classcounter + 1if d <> "" then classcounter = classcounter + 1if e <> "" then classcounter = classcounter + 1if f <> "" then classcounter = classcounter + 1%> I need to know how to convert this to js so I can show this number to the user without sending data to the server first. I have searched the net for something similar but I am not having much luck finding any examples that do what I would like it to do (maybe this is not something that can/should be done in js?).I hope this makes sense...thanks! Link to comment Share on other sites More sharing options...
justsomeguy Posted September 9, 2009 Share Posted September 9, 2009 What are a through f? This would be strictly equivalent to what you have (you're using 2 different variable names for the counter though), but it's not going to really do anything since a through f are undefined. var counter = 0;if (a != '') counter++;if (b != '') counter++;if (c != '') counter++;etc Link to comment Share on other sites More sharing options...
jbsmith Posted September 9, 2009 Author Share Posted September 9, 2009 What are a through f?a through f are variables that get filled from the asp page. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 9, 2009 Share Posted September 9, 2009 If this is Javascript running in the browser, it's not going to have access to any variables in the ASP code, not unless you explicitly give it access (write out the values into Javascript variables). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.