Using a variable as dynamic text

M

mao

I'm trying to use a variable to:
1. Display a variable called day1 as text.
2. Pass the contents of day1 to a function which requires a string.

Given this code which currently works to display a given page like
'page-1.html', 'page-2.html'...:

<html>
<head>
<title>Your Site's Title Here</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var day1=1;
function loadDay(day) {
href=eval("parent.Frame_B.location='page-"+day+".html'");
}
// End -->
</script>
</head>

<BODY>
<body bgcolor="#FFFFFF">
<table border="0">
<tr>
<td><a OnClick=loadDay('1');>1</a></td>
<td><a OnClick=loadDay('2');>2</a></td>
<td><a OnClick=loadDay('3');>3</a></td>
</tr>
</table>
</body>

</BODY>

I would like to code the OnClick portion something like this pseudocode:

<td><a OnClick=loadDay(day1);>day1</a></td>
<td><a OnClick=loadDay(day1+1);>day1+1</a></td>
<td><a OnClick=loadDay(day1+2);>day1+2</a></td>

so that the day1 variable is converted to a string to be passed to the
loadDay() function and also is displayed as text in the table. Can someone
help?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top