By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

A probable solution perhaps?

P: n/a
So sweet and simple.
Found this script on a board.

<script type="text/javascript">

function showtext(thetext) {
if (!document.getElementById) return false;
document.getElementById("toggle").innerHTML = thetext;
}
</script>
<a href="#" onClick="showtext('text A'); return false">link 1</a> <br>
<a href="#" onClick="showtext('text B'); return false">link 2</a>
<div id="toggle"></div>

Question is, can I replace ("textA") with a variable like (text[1]) ??

Jul 23 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Sat, 22 Jan 2005 12:10:49 -0600 Richard wrote:
So sweet and simple.
Found this script on a board. <script type="text/javascript"> function showtext(thetext) {
if (!document.getElementById) return false;
document.getElementById("toggle").innerHTML = thetext;
}
</script>
<a href="#" onClick="showtext('text A'); return false">link 1</a> <br>
<a href="#" onClick="showtext('text B'); return false">link 2</a>
<div id="toggle"></div> Question is, can I replace ("textA") with a variable like (text[1]) ??

The answer is YES!
Works out so nicely I can now easily add descriptions with but a simple
array.

Jul 23 '05 #2

P: n/a
On Sat, 22 Jan 2005 12:10:49 -0600, Richard <An*******@127.001> wrote:
So sweet and simple.


....and completely inaccessible.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

P: n/a
On Sat, 22 Jan 2005 19:27:29 GMT Michael Winter wrote:
On Sat, 22 Jan 2005 12:10:49 -0600, Richard <An*******@127.001> wrote:
So sweet and simple.

...and completely inaccessible.


I just tested it in IE6 and you are right, it does not work.
So maybe I'll find something that will work in both then.
I don't see why IE refuses it though.


Jul 23 '05 #4

P: n/a
On Sat, 22 Jan 2005 13:47:46 -0600, Richard <An*******@127.001> wrote:
On Sat, 22 Jan 2005 19:27:29 GMT Michael Winter wrote:


[snip]
[...] completely inaccessible.


I just tested it in IE6 and you are right, it does not work.


Whether something "works" has nothing to do with its accessibility.

The fact that such an approach relies on a script to provide content
(completely unnecessarily, I might add) makes it unsuitable for the Web in
general as only scriptable browsers (that support innerHTML) can make
sense of the document.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5

P: n/a
On Sat, 22 Jan 2005 20:35:59 GMT Michael Winter wrote:
On Sat, 22 Jan 2005 13:47:46 -0600, Richard <An*******@127.001> wrote:
On Sat, 22 Jan 2005 19:27:29 GMT Michael Winter wrote: [snip]
[...] completely inaccessible.
I just tested it in IE6 and you are right, it does not work.

Whether something "works" has nothing to do with its accessibility. The fact that such an approach relies on a script to provide content
(completely unnecessarily, I might add) makes it unsuitable for the Web
in
general as only scriptable browsers (that support innerHTML) can make
sense of the document. [snip]


Then why do we even have damn browsers if all they will do is render html?
The content presented in my case is not all that necessary, it is purely for
providing a short description of the image.
Of course, I could use a flaky tool tip thingy, but even that is crap.
I am looking at doing this in a bit more professional way.

During my surfing session today, I did run across one site which does
precisely what I want to do.
Where they had the main content swap in accordance with your choice from a
dropdown box.
But I couldn't figure out how they addressed the script page.
Jul 23 '05 #6

P: n/a
In article <cs*********@news1.newsguy.com>, An*******@127.001 says...
On Sat, 22 Jan 2005 20:35:59 GMT Michael Winter wrote:
On Sat, 22 Jan 2005 13:47:46 -0600, Richard <An*******@127.001> wrote:
On Sat, 22 Jan 2005 19:27:29 GMT Michael Winter wrote:
[snip]

[...] completely inaccessible. I just tested it in IE6 and you are right, it does not work.

Whether something "works" has nothing to do with its accessibility.

The fact that such an approach relies on a script to provide content
(completely unnecessarily, I might add) makes it unsuitable for the Web
in
general as only scriptable browsers (that support innerHTML) can make
sense of the document.

[snip]


Then why do we even have damn browsers if all they will do is render html?


That's what browsers are for, Stupid.
The content presented in my case is not all that necessary
Agreed.

Of course, I could use a flaky tool tip thingy, but even that is crap.
You're used to producing crap aren't you, Bullis?

I am looking at doing this in a bit more professional way.


ROTFLMAO!

--
Hywel http://kibo.org.uk/
I do not eat quiche.
Jul 23 '05 #7

P: n/a
Hywel Jenkins wrote on 23 jan 2005 in comp.lang.javascript:
Then why do we even have damn browsers if all they will do is render
html?


That's what browsers are for, Stupid.


My IE6 happily shows a text-file, like <http://x.com/y.txt>

IE will also forward specific files to it's specialized programme,
like Realplayer, windowsmediaplayer, adobeviewer,
or plugins,
like flash, etc.

btw "rendering" [extract to,deliver to,depict as,translate into]
in the html sense is more a serverside code action IMHO.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #8

P: n/a
Richard (RtS) wrote:
Michael Winter wrote: <snip>
... makes it unsuitable for the Web in general as only
scriptable browsers (that support innerHTML) can make
sense of the document.


Then why do we even have damn browsers if all they
will do is render html?


The minimum requirement for a web browser is that it be able to retrieve
an HTML document and (in some sense) present its contents to the user.
If it cannot do that then it is not a web browser, but if it does
anything more then that is an optional extra. Making accessing content
dependent upon optional technologies is a mistake, and a demonstrably
avoidable mistake at that.
The content presented in my case is not all that
necessary, it is purely for providing a short description
of the image. Of course, I could use a flaky tool tip thingy, but even
that is crap.
Apparently that is not true as you have manifestly failed to
successfully implement even one of the copy-and-paste scripts that you
have been trying to use, and trying to adopt scripts that were not
designed for copy-and-paste (copyright issues not withstanding) was
never a viable activity as that will always require a real understanding
of browser scripting.
I am looking at doing this in a bit more professional way.
A professional presented with a problem outside of their skill-set will
either: 1. Acquire then necessary skills. 2. Hire the services of
another professional who already has those skills. Usually the latter as
the former is too time consuming to address most current problems (but
might still be seen as an appropriate course of action in anticipation
of similar problems occurring in the future).

What a professional will not do is spend two months spinning their
wheels looking for some sort of panacea script on the internet, the
implementation of which, if ever found, would be beyond them anyway.

One of the things that makes you intermittently posted, self satisfied
"progress" reports particularly unwelcome is that everyone reading them
knows that you are progressing from nothing, towards nothing. Your whole
approach is fatally flawed; you cannot successfully use scripting on the
Internet without first acquiring the pertinent skills, and you haven't
even grasped HTML yet let alone the added complexity of perceiving the
additional mechanism involved in scripting.
During my surfing session today, I did run across one
site which does precisely what I want to do.
Where they had the main content swap in accordance with
your choice from a dropdown box.
Yes, it is trivial to do it. The only significant issues are designing
the script so that it does not introduce unnecessary dependencies, and
is reliable in its execution or clean degradation.
But I couldn't figure out how they addressed the script page.


When conversing with people who have (at best) a slight understanding of
a technical subject throwing in a little tech-speek might impress. In
the context of a technical newsgroup the misuse of technical language
will only make it obvious that you don't know what you are talking
about, but are trying (for some unfathomable reason) to pretend
otherwise.

It is not "how they address the scripted page" that you could not figure
out (that is a meaningless statement). What you cannot figure out is;
what it is that you need to be able to figure out. And that is because
you have not yet grasped the basics of the subject, though you appear to
also be incapable of perceiving that.

To script a web browser for the internet you first need to know (at
minimum):-

1. The basic syntax and use of javascript (and eventually the details,
if you every hope to take full advantage of the language).

2. The browser object model; its structure and behaviour. (For which it
is necessary to understand how the DOM relates to (x)HTML source code.
Which, in turn requires a technical understanding of HTML.)

3. The differences between, and variability in, browser object models,
and the techniques for handling those differences.

4. The issues pertinent to web browser scripting; reliability, clean
degradation, accessibility, etc, etc.

From that basis you can move on to the bigger problems of script design
for the Internet, and so be in a position to produce something worth
talking about.

From your current position of having no comprehension of any of the
above, and apparently no interest in (or talent for) learning about
them, you can only waste your time. Which is fine, so long as you don't
bother anyone else with your nonsense.

Richard.
Jul 23 '05 #9

P: n/a
JRS: In article <cs*********@news1.newsguy.com>, dated Sat, 22 Jan 2005
12:10:49, seen in news:comp.lang.javascript, Richard <An*******@127.001>
posted :
So sweet and simple.
Found this script on a board.
You should have left it there.

function showtext(thetext) {
if (!document.getElementById) return false;
document.getElementById("toggle").innerHTML = thetext;
}


That function returns either false or undefined; that's not a well-
designed combination.

In reading recent articles in this newsgroup, you should have seen a
thread containing

if (document.all && !document.getElementById) {
document.getElementById = function(id) {
return document.all[id] } }

If that code is executed before showtext is called, showtext will work
equally well in older versions of MSIE, under reasonable assumptions
about "toggle".

For versatility, supply the location as a parameter to showtext.

The code can then be put in an include file, and used on various pages.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.