Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window alert does not work

Status
Not open for further replies.

leifoet

Technical User
Jan 31, 2016
203
BE
Variable SN in the window alert must be 'John' but is displayed as 'undefined'.
Thanks for solution tips.

<%
session("Mem")="John"
%>

<script>
<%
sesname=session("Mem")
%>

var SN = <%=sesname%>;

function myFunction()

{
alert("Dear "+SN+",\n...");
}
</script>
<script>myFunction();</script>
 
What does the rendered source code look like?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
The output is this



Code:
<script>
 
var SN = John;

function myFunction() 

{
alert("Dear "+SN+",\n...");
}
</script>
<script>myFunction();</script>

So if you put a single quote around the value assigned to the value SN...

Code:
var SN = '<%=sesname%>';

...you should be all set.
 
<script>
function myFunction() {
var SN = <%=session("Mem")%>;
alert("Dear "+SN+",\n...");
}
return myFunction()
</script>

or

<script>
var SN = <%=session("Mem")%>;
alert("Dear "+SN+",\n...");
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top