Solved

ASP to Javascript

Posted on 2014-11-10
3
157 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

785 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