B
Byron
Hi,
Javascript confuses me, so I usually limit myself to Dreamweaver's
built-in scripts for stuff like imageswaps. But this time I'm trying to
write something very simple myself. I do most of my stuff in ASP and PHP
so I'm familiar with server-side programming; for some reason JavaScript
syntax trips me up.
I want to assign a value to a variable according to an onclick event,
and then run an if...then on the variable, and according to the value
write some text to the page.
Here's my (relevant) code:
<!-- -- start -- -->
<head>
<SCRIPT type="text/Javascript">
var sketcharrow = 1;
</SCRIPT>
</head>
<!-- -- snip -- -->
<td><SCRIPT type="text/Javascript">
if (sketcharrow == 1) {
document.write("«");
}
</SCRIPT>
</td>
<td><SCRIPT type="text/Javascript">
if (sketcharrow == 2) {
document.write("»");
}
</SCRIPT>
</td>
<!-- -- snip -- -->
<A href="#" onClick="sketcharrow = 2;MM_swapImage
('logo','','/sketches/mixmatch/20050301.EQ.jpg',1);MM_setTextOfLayer
('logoinfo','','<h1>Logo: Spoke Equality</h1>')">Spoke Equality</A>
<!-- -- end -- -->
The page loads fine, with the text for the conditional sketcharrow == 1
writing as planned. But when I click on the link to change sketcharrow
== 2 the if...thens don't get the new value to work with, although the
other two onClick events execute perfectly.
I am a total novice with Javascript, so any illumination would be
greatly appreciated. Can anyone help? Is what I'm trying even possible?
Thanks.
Javascript confuses me, so I usually limit myself to Dreamweaver's
built-in scripts for stuff like imageswaps. But this time I'm trying to
write something very simple myself. I do most of my stuff in ASP and PHP
so I'm familiar with server-side programming; for some reason JavaScript
syntax trips me up.
I want to assign a value to a variable according to an onclick event,
and then run an if...then on the variable, and according to the value
write some text to the page.
Here's my (relevant) code:
<!-- -- start -- -->
<head>
<SCRIPT type="text/Javascript">
var sketcharrow = 1;
</SCRIPT>
</head>
<!-- -- snip -- -->
<td><SCRIPT type="text/Javascript">
if (sketcharrow == 1) {
document.write("«");
}
</SCRIPT>
</td>
<td><SCRIPT type="text/Javascript">
if (sketcharrow == 2) {
document.write("»");
}
</SCRIPT>
</td>
<!-- -- snip -- -->
<A href="#" onClick="sketcharrow = 2;MM_swapImage
('logo','','/sketches/mixmatch/20050301.EQ.jpg',1);MM_setTextOfLayer
('logoinfo','','<h1>Logo: Spoke Equality</h1>')">Spoke Equality</A>
<!-- -- end -- -->
The page loads fine, with the text for the conditional sketcharrow == 1
writing as planned. But when I click on the link to change sketcharrow
== 2 the if...thens don't get the new value to work with, although the
other two onClick events execute perfectly.
I am a total novice with Javascript, so any illumination would be
greatly appreciated. Can anyone help? Is what I'm trying even possible?
Thanks.