Solved

ASP to Javascript

Posted on 2014-11-10
3
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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 …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to count occurrences of each item in an array.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

705 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