Solved

ASP to Javascript

Posted on 2014-11-10
3
148 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article discusses how to create an extensible mechanism for linked drop downs.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to count occurrences of each item in an array.

763 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

8 Experts available now in Live!

Get 1:1 Help Now