Now you can post the full ( working ) asp version ¥
Alrite. I changed my code back to follow your code (the original) and just translate it (as literally as possible) to classic ASP.
HTML
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-UK" lang="en-UK">
<head>
<title>test</title>
</head>
<body>
<label for="theText">Type in the text to be reversed : <input type="text" name="theText" id="theText" /></label>
<button onclick="reverseMe();">Reverse</button>
<script type="text/javascript">
function reverseMe()
{
var theText = document.getElementById( 'theText' ).value; // grab the text
var the_call = document.createElement( 'script' ); // create script element
the_call.src = 'nonAjax.asp?theString='+theText; // set the url
the_call.type = 'text/javascript'; // to be sure to be sure
document.body.appendChild( the_call ); // add script to body and let browser do the rest
}
function serversReply( theAnswer )
{
window.alert( 'The server said : '+theAnswer ); // stun the crowd with a reply from the server
}
</script>
</body>
</html>
ASP (nonAjax.asp)
Code:
<%
Response.ContentType = "text/javascript" ' set the correct mime type
theText = request.querystring("theString") ' grab the text to be reversed
If theText = "" then
theAnswer = "Gimme summat to do!" ' inform the user we're bored
else ' we have some text, reverse it
theAnswer = strReverse(theText) ' reverse the text
end if
theAnswer = replace(theAnswer,"'","") ' single quotes would break the reply
response.write("serversReply('" & theAnswer & "');") 'trigger the function on the calling page
%>
(actually what tag shouid I use to wrap asp code?)
You aren't violating this post ... and even if you were, I don't have the power to delete you .... so you're safe
I'm glad that this inspired you to expand it's use, but ( there's always a but ) ... in keeping with the "lets play with the dom" you might like to replace all your innerHTML ( ++ the string that's built before hand ) with document.createElement('div') ... etc (urm.. hunts for link ... found it dom stuff )
Appreciate your work though
¥
__________________
I may have opened the door, but you entered of your own free will