Wen wrote:
Hi Ray,
Thank you so much!! It works.
Not quite. JScript uses 0-based months, so you may want to use d.getMonth()
+ 1.
ALSO -- A note of caution: This only works because the default server-side
language is VBScript. I know this because you are mixing <script
runat=server> with <%%> blocks, and there is an order of operations. To see
this in action, move your server-side JScript block to the very end of your
script, and you'll note that it still works:
<script language="javascript">
alert("<%=Time%> on <%=datum%>")
</script>
<script language="JScript" runat="server">
var d = new Date()
var dd = d.getDate()
var mm = d.getMonth()
var yyyy = d.getFullYear();
var datum = dd + "-" + mm + "-" + yyyy
</script>
A far better approach to mixing languages on the server is to encapsulate
those elements into functions (or Subs). Either of those can be called from
any other block, regardless of the parsing order. Example:
<script language="javascript">
alert("<%=Time%> on <%=getDate()%>")
</script>
<script language="JScript" runat="server">
function getDate() {
var d = new Date()
return d.getDate() + "-" +
d.getMonth() + "-" +
d.getFullYear()
}
</script>
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.