Solved

ASP to Javascript

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AngularJS: ng-repeat 25 54
Split on ASP 8 50
Different Javascript on iPhone than Win 10 desktop? 7 53
Drag & Drop Error 5 31
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

734 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