Link to home
Start Free TrialLog in
Avatar of Terry Rogers
Terry RogersFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Convert .asp page to .HTML

We currently have a asp file with the following code:-

<%@ LANGUAGE=JSCRIPT %>
<%

// VARS TO CHANGE

var v1 = 12345;
var v2 = 12345678;
var targetFile = "mysecretpage.asp"

// END VARS TO CHANGE

var enterpriseName = targetFile.substr(0,targetFile.lastIndexOf("."));

function pad(num){
  return(num<10?"0"+num.toString():num.toString());
}

var now = new Date();

var key = pad(now.getUTCMinutes()) + pad(now.getUTCMonth()) + pad(now.getUTCDate()) + pad(now.getUTCHours());
key = (key * v1) - v2;

%>


<HTML><BODY onload="document.uptodate.submit();">

<form method="POST" action="http://uptodateonline.com/porthole/<%= targetFile %>" name="uptodate">
<input type="hidden" value="<%= enterpriseName %>" name="username">
<input type="hidden" value="<%= key %>" name="key">
<input type="submit" value="UpToDate">

</form>
</BODY></HTML>

Open in new window


I have amended the variables for security reasons.

I need to convert this code into a standard HTML file as server side scripting is disabled on our particular web server and we are unable to get it enabled.

My understanding is that this is simple Javascript so it should be possible to integrate this into a standard HTML page?

Any help would be appreciated as my experience with Javascript is minimal.
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

There's nothing in that code that's ASP-specific (except for the "mysecretpage.asp" reference, and that's another page).  There's no obvious reason you couldn't just rename this from myfile.asp to myfile.html.
Avatar of Terry Rogers

ASKER

Hi Paul,

Thank you for your comment.

I have changed the file extension and the page loads, but with error:-

User generated image
In addition, after ok'ing the error, the button does nothing and the page does not automatically load into the required url.
That's a javascript issue, and I'm afraid I can't be much help there.

I'll see if I can get an admin to update the tags on your question.
The parts of your form where you set the values are specific to ASP, so you'll need to populate that with Javascript instead. You'll also need to ensure that your Javascript code doesn't run until the page is fully loaded (onLoad event or the jQuery document.ready method):

function setup()
{
    var v1 = 12345;
    var v2 = 12345678;
    var targetFile = "mysecretpage.asp"

    var enterpriseName = targetFile.substr(0,targetFile.lastIndexOf("."));
    var now = new Date();
    var key = ((pad(now.getUTCMinutes()) + pad(now.getUTCMonth()) + pad(now.getUTCDate()) + pad(now.getUTCHours())) * v1) - v2;
    var myForm = document.forms['uptodate'];

    myForm.action = "http://uptodateonline.com/porthole/" + targetFile;
    myForm.elements["username"].value = enterpriseName;
    myForm.elements["key"].value = key;
}

function pad(n) {
    return (n < 10) ? ("0" + n) : n;
}

Open in new window

Hi Chris,

Thank you for your comment.

My knowledge of HTML and Javascript is limited.

How would I fit that javascript code into a HTML page?

Regards
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bear in mind that there is absolutely zero security in doing this. It's very easy to see the source of your page, and therefore the mechanics used to generate the key. Don't know if that's a problem for you but thought it worth mentioning
Thank you! Works a treat! :)