I want to place an image next to
the currently selected text:
[URL=”http://www.anothenservices.com/public/relative_strength/jscrpt_ranking.html”]Relative Strength Calculator
In the Ranked section, when a currency is selected;
for example “USD” would display a US Flag image.
PHP sure would make this easier.
Portions of the code:
[code=php]
<script type=”text/javascript”>
..code..
..code that determines array “ranked_currencies()”;..
f=document.calculator;
f.first.value = ranked_currencies[0];
f.second.value = ranked_currencies[1];
f.third.value = ranked_currencies[2];
f.fourth.value = ranked_currencies[3];
f.fifth.value = ranked_currencies[4];
f.sixth.value = ranked_currencies[5];
f.seventh.value = ranked_currencies[6];
f.eighth.value = ranked_currencies[7];
..code..
</script>
… html code …
<form name=”calculator” method=”post” action=””>
..code..
1<input name=”first” id=”first” size=”2″ disabled><br>
2<input name=”second” size=”2″ disabled><br>
3<input name=”third” size=”2″ disabled><br>
4<input name=”fourth” size=”2″ disabled><br>
5<input name=”fifth” size=”2″ disabled><br>
6<input name=”sixth” size=”2″ disabled><br>
7<input name=”seventh” size=”2″ disabled><br>
8<input name=”eighth” size=”2″ disabled><br>
..code..
</form>
Above is portions of the code that I would like
to edit. I’ve tried several methods, but it’s not
like PHP at all. Javascript is very strict on how
it deals with variables.
My first idea was to put a javascript code there:
[code=php]
1<input name=”first” id=”first” size=”2″ disabled>
<script type=”text/javascript”>
var what_currency = document.getElementById(“first”);
switch(what_currency)
{ case “USD” : document.write(“<img scr=”usd.png” />”) break;
case “JPY” : document.write(“<img scr=”jpy.png” />”) break;
.. code
.. code
} </script>
<br>
Now I know that the code above does not work.
and I do know that I could do this in PHP which
would solve everything, but I’m really trying to
learn Javascript.
Isn’t there a way I could use ” getElementById()” without
having to enable an event?