![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 -- -- [snip] |
#3
| |||
| |||
|
|
You're right, this approach is flawed (calling document.write() after the page is loaded). A simple function may suffice function changeArrow(num){ document.getElementById.innerHMTL=num==2?"<":">"; } |
|
A href="#" onclick="changeArrow(2);... " Mick |
#4
| ||||
| ||||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |