Page 1 of 1

make link no longer a link

Posted: Fri Mar 24, 2006 2:26 am
by shiznatix
Ok so I have about 4 textareas and some links above them. When you click the link it makes the appropriate text area appear and the rest disappear. What I want to do is make the link that I clicked on no longer a link (ie, just text) so the person knows what textarea they are using. Here is my code:

Code: Select all

<script type="text/javascript">
            function show(id, tot)
            {
                for (i = 0; i < tot; i++)
                {
                    targ = document.getElementById(i);
              
                    if (i != id)
                        targ.style.display = 'none';
                    else
                        targ.style.display = '';
                }
            }
</script>

|| <a href="#" onclick="show('0', '4')">eng</a>
|| <a href="#" onclick="show('1', '4')">est</a>
|| <a href="#" onclick="show('2', '4')">rus</a>
|| <a href="#" onclick="show('3', '4')">fin</a>
|| <a href="#" onclick="show('none', '4')">Hide All</a>
<br />
<textarea rows="5" cols="40" id="0" style="display: none" name="additional[eng]"></textarea>
<textarea rows="5" cols="40" id="1" style="display: none" name="additional[est]"></textarea>
<textarea rows="5" cols="40" id="2" style="display: none" name="additional[rus]"></textarea>
<textarea rows="5" cols="40" id="3" style="display: none" name="additional[fin]"></textarea>
edit: I had to change the naming to be standards complient but now it does not work. Here is the new, trying to be standards complient, section:

Code: Select all

<script type="text/javascript">
            function show(id, tot)
            {
                for (i = 0; i < tot; i++)
                {
                    targ = document.getElementById('a'.i);
              
                    if ('a'.i != id)
                        targ.style.display = 'none';
                    else
                        targ.style.display = '';
                }
            }
          </script>
 || <a href="#" onclick="show('a0', '4')">eng</a>
 || <a href="#" onclick="show('a1', '4')">est</a>
 || <a href="#" onclick="show('a2', '4')">rus</a>
 || <a href="#" onclick="show('a3', '4')">fin</a>
 || <a href="#" onclick="show('none', '4')">Hide All</a>

<textarea rows="5" cols="40" id="a0" style="display: none" name="additional[eng]"></textarea>
<textarea rows="5" cols="40" id="a1" style="display: none" name="additional[est]"></textarea>
<textarea rows="5" cols="40" id="a2" style="display: none" name="additional[rus]"></textarea>
<textarea rows="5" cols="40" id="a3" style="display: none" name="additional[fin]"></textarea>

Posted: Fri Mar 24, 2006 2:41 am
by feyd

Code: Select all

'a' + i

Posted: Fri Mar 24, 2006 2:53 am
by shiznatix
ahha silly me. Another odd thing is that I have a 'warning'. It says

character "<" is the first character of a delimiter but occurred as data.

it is talking about the < in the for loop of the javascript. The javascript is not located in the header but it does not give me any guff about that.

But more important to me is the original question i had.