Solved

ASP to Javascript

Posted on 2014-11-10
3
154 Views
Last Modified: 2014-11-10
Hi!
I have built an advent calender in ASP and now i wanna know if i can rebuild it in JavaScript (im not good at JavaScript), i just want the if else to work at the same way like it is in my code. I want plain html between the if else.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>
<%
Dim Dagens
response.write(Day(date))
Dagens = (Day(date))
%>
<% 
if Dagens => 1 then
 %>
			<li class="active" id="ak1">
				<a href="http://www.adlibris.com">
					<p>Dagens bok</p>
					<div class="left"><span aria-hidden="true">1</span></div>
				  <div class="right"></div>
			  </a>
			</li>
			<% Else %>
						<li class="inactive" id="ak1" title="Denna lucka &ouml;ppnas tidigast den 1:e December.">
				<p>Denna lucka &ouml;ppnas tidigast den 1:e December.</p>
				<div class="left"><span aria-hidden="true">1</span></div>
			  <div class="right"></div>
			</li>
			<% End If %>
<% 
if Dagens => 2 then
 %>
			<li class="active" id="ak2">
				<a href="http://www.adlibris.com">
					<p>Dagens bok2</p>
					<div class="left"><span aria-hidden="true">2</span></div>
				  <div class="right"></div>
			  </a>
			</li>
						<% Else %>
						<li class="inactive" id="ak2" title="Denna lucka &ouml;ppnas tidigast den 2:e December.">
				<p>Denna lucka &ouml;ppnas tidigast den 2:e December.</p>
				<div class="left"><span aria-hidden="true">2</span></div>
			  <div class="right"></div>
			</li>
			<% End If %>

</body>
</html>

Open in new window

0
Comment
Question by:MickeC
  • 2
3 Comments
 
LVL 4

Expert Comment

by:Ersoy Hasan
ID: 40432435
Only one thing where does "date" come in new Day(date) ?
<%@ Language=JScript %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title>Untitled</title>
</head>

<body>
<%
var Dagens;
// where does date come from ?
Response.Write(new Day(date))
Dagens = (new Day(date))
%>
<% if (Dagens => 1) { %>
            <li class="active" id="ak1">
                <a href="http://www.adlibris.com">
                    <p>Dagens bok</p>
                    <div class="left"><span aria-hidden="true">1</span></div>
                  <div class="right"></div>
              </a>
            </li>
<% } else { %>
                        <li class="inactive" id="ak1" title="Denna lucka &ouml;ppnas tidigast den 1:e December.">
                <p>Denna lucka &ouml;ppnas tidigast den 1:e December.</p>
                <div class="left"><span aria-hidden="true">1</span></div>
              <div class="right"></div>
            </li>
<% } %>
<% if (Dagens => 2) { %>
            <li class="active" id="ak2">
                <a href="http://www.adlibris.com">
                    <p>Dagens bok2</p>
                    <div class="left"><span aria-hidden="true">2</span></div>
                  <div class="right"></div>
              </a>
            </li>
<% } else { %>
                        <li class="inactive" id="ak2" title="Denna lucka &ouml;ppnas tidigast den 2:e December.">
                <p>Denna lucka &ouml;ppnas tidigast den 2:e December.</p>
                <div class="left"><span aria-hidden="true">2</span></div>
              <div class="right"></div>
            </li>
<%}%>

</body>
</html>

Open in new window

There are a lot of cool stuff you can use in ASPClassic JScript implementation. You can use object notation, Douglas Crockford's JSON library for javascript. You can make services that return JSON and many more ... :)
0
 

Author Comment

by:MickeC
ID: 40432466
Hi! I only use day in date eg. 2 for 2:e December and so on, its purpose are only to prevent the user to open a "door" in the calender before the right day.

In the variable "Dagens" is the currently day stored, for example if the date is 2:e December, the there is number two in variable and then i put this in the code if (Dagens => 2) then "show html code for the open door" else "show html code for the closed door".
0
 
LVL 4

Accepted Solution

by:
Ersoy Hasan earned 500 total points
ID: 40432478
Ok then Dagens variable will look like this:
Dagens = date.getDate()

Open in new window

here you can see reference on how you can work with Date objects:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint 2013 List with Ratings 6 36
Don't understand jquery promises 6 37
Javascript and Jquery not firing 9 40
what is the difference between call and apply 1 26
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now