Jump to content

Converting Asp To Js


jbsmith
 Share

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...