473,386 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Adding text to an HTML page

A complete js newbie is asking this question:

I have a form comprised of several questions, each answered with a radio
button. I'd like to use onClick to bring up additional text at the end of
the form (not in a text box). I've tried using document.write("yada"), but
it clears the page before showing the text. How can I do it?

BTW, I'm currently using js in conjunction with CSS to unhide the text.
This works fine, except it requires large blank blocks of space on the
page, unless the text is shown. Looks bad.

--
Ed Jay (remove M to respond by email)
Nov 10 '05 #1
32 2109
Ed Jay wrote:
A complete js newbie is asking this question:

I have a form comprised of several questions, each answered with a radio
button. I'd like to use onClick to bring up additional text at the end of
the form (not in a text box). I've tried using document.write("yada"), but
it clears the page before showing the text. How can I do it?
Read the FAQ - it's posted here twice per week 'comp.lang.javascript FAQ':

<URL:http://www.jibbering.com/faq/>


BTW, I'm currently using js in conjunction with CSS to unhide the text.
This works fine, except it requires large blank blocks of space on the
page, unless the text is shown. Looks bad.


Toggle the div between style.display = '' and 'none'. There are plenty
of examples in the archives, search for 'toggle display none' and sort
by date.

--
Rob
Nov 10 '05 #2
RobG <rg***@iinet.net.au> wrote:
Ed Jay wrote:
A complete js newbie is asking this question:

I have a form comprised of several questions, each answered with a radio
button. I'd like to use onClick to bring up additional text at the end of
the form (not in a text box). I've tried using document.write("yada"), but
it clears the page before showing the text. How can I do it?


Read the FAQ - it's posted here twice per week 'comp.lang.javascript FAQ':

<URL:http://www.jibbering.com/faq/>


BTW, I'm currently using js in conjunction with CSS to unhide the text.
This works fine, except it requires large blank blocks of space on the
page, unless the text is shown. Looks bad.


Toggle the div between style.display = '' and 'none'. There are plenty
of examples in the archives, search for 'toggle display none' and sort
by date.


Thanks, Rob. FWIW I've scoured the FAQ for hour and this NG's posts for
the past year trying to find the solution, all to no avail. I apologize
for my blindness.

--
Ed Jay (remove M to respond by email)
Nov 10 '05 #3
Ed Jay wrote:
RobG <rg***@iinet.net.au> wrote:
Ed Jay wrote:
A complete js newbie is asking this question:

I have a form comprised of several questions, each answered with a radio
button. I'd like to use onClick to bring up additional text at the end of
the form (not in a text box). I've tried using document.write("yada"), but
it clears the page before showing the text. How can I do it?

Read the FAQ - it's posted here twice per week 'comp.lang.javascript FAQ':

<URL:http://www.jibbering.com/faq/>

BTW, I'm currently using js in conjunction with CSS to unhide the text.
This works fine, except it requires large blank blocks of space on the
page, unless the text is shown. Looks bad.

Toggle the div between style.display = '' and 'none'. There are plenty
of examples in the archives, search for 'toggle display none' and sort
by date.


Thanks, Rob. FWIW I've scoured the FAQ for hour and this NG's posts for
the past year trying to find the solution, all to no avail. I apologize
for my blindness.


FAQ:
<URL:http://www.jibbering.com/faq/#FAQ4_15>

Post - hey, one of mine :-)
<URL:http://groups.google.co.uk/group/comp.lang.javascript/browse_frm/thread/892475e53aacd31a/217b782a199a2b96?q=display+none+toggle+showhide&rn um=3#217b782a199a2b96>


--
Rob
Nov 10 '05 #4

RobG wrote:
FAQ:
<URL:http://www.jibbering.com/faq/#FAQ4_15>


This is slightly OT, but I wondered about these 2 statements in the FAQ
script:

DocDom = (document.getElementById?true:false);

DocAll = (document.all?true:false);
Why not simply the following?
DocDom = document.getElementById

DocAll = document.all
Nigel

--
ScriptMaster language resources (Chinese/Modern & Classical
Greek/IPA/Persian/Russian/Turkish):
http://www.elgin.free-online.co.uk

Nov 10 '05 #5
>>> Ed Jay wrote:
A complete js newbie is asking this question:

I have a form comprised of several questions, each answered with a radio
button. I'd like to use onClick to bring up additional text at the end of
the form (not in a text box)...


Progress. This seems to be working properly, but it also seems much too
simple:

<script language="Javascript">

function show(msg) {
target = document.getElementById(msg);
target.style.display = "";
}

function hide(msg) {
target = document.getElementById(msg);
target.style.display = "none";
}

</script>

<FORM ACTION="url" METHOD="POST">

Show-1: <input type=radio name="name1" onClick="show('div1')">
Hide-1: <input type=radio name="name1" onClick="hide('div1')">

Show-2: <input type=radio name="name2" onClick="show('div2')">
Hide-2: <input type=radio name="name2" onClick="hide('div2')">

</Form>

<div id="div1" style="display:none">
This is message 1.
</div>

<div id="div2" style="display:none">
This is message 2.
</div>

--
Ed Jay (remove M to respond by email)
Nov 10 '05 #6
Nigel Greenwood wrote:
RobG wrote:
FAQ:
<URL:http://www.jibbering.com/faq/#FAQ4_15>


This is slightly OT, but I wondered about these 2 statements in the FAQ
script:

DocDom = (document.getElementById?true:false);
DocAll = (document.all?true:false);

Why not simply the following?

DocDom = document.getElementById
DocAll = document.all


Because the latter would force implicit type conversion (to Boolean)
later and, regarding code reuse, DocDom() will not work instead of
document.getElementById(). However, I'd rather use

var bDocDom = !!document.getElementById;
var bDocAll = !!document.all;

However, it would still not suffice as feature test. For example:
document.getElementById may be something injected client-side into
the DOM to work around browser detection or to emulate DOM Level 2
support where there in fact is none; document.all is available in
Opera as well but does not provide the same functionality as in IE.
PointedEars
Nov 10 '05 #7
Ed Jay wrote:
Ed Jay wrote:

>A complete js newbie is asking this question:
>
>I have a form comprised of several questions, each answered with a radio
>button. I'd like to use onClick to bring up additional text at the end of
>the form (not in a text box)...


Progress. This seems to be working properly, but it also seems much too
simple:

<script language="Javascript">


The language attribute is depreciated, type is required:

<script type="text/javascript">


function show(msg) {
target = document.getElementById(msg);
target.style.display = "";
}

function hide(msg) {
target = document.getElementById(msg);
target.style.display = "none";
}


Why not replace both with a single 'toggle' function and then use a
checkbox (feature testing added also):

function showHide(cb, id)
{
if (document.getElementById)
var el = document.getElementById(id);

if (el && el.style)
el.style.display = (cb.checked)? '' : 'none';
}
</script>
Show 1? <input type="checkbox" onclick="showHide(this, 'div1')">
Show 2? <input type="checkbox" onclick="showHide(this, 'div2')">
[...]

--
Rob
Nov 10 '05 #8
Ed Jay wrote:

Please provide proper attribution, see
<http://jibbering.com/faq/faq_notes/pots1.html>.
vvvvvvvvvvvvvvvvvv
Ed Jay wrote:
> A complete js newbie is asking this question:
>
> I have a form comprised of several questions, each answered with a
> radio button. I'd like to use onClick to bring up additional text at
> the end of the form (not in a text box)...

Progress. This seems to be working properly, but it also seems much too
simple:

<script language="Javascript">


The `language' attribute is deprecated in HTML4, the `type' attribute
is #REQUIRED.
function show(msg) {
target = document.getElementById(msg);
target.style.display = "";
You want to test whether document.getElementById() returned a useful
object reference:

if (target
&& typeof target.style != "undefined"
&& typeof target.style.display != "undefined")
{
target.style.display = "";
}

See also <http://pointedears.de/scripts/dhtml.js>, setStyleProperty().

You probably want to declare the variable with the `var' keyword because
otherwise it becomes global.

That said, it would be more efficient to retrieve the object reference
only once and reuse the variable storing it when needed which may and
may not be achieved using globals.
}

function hide(msg) {
target = document.getElementById(msg);
target.style.display = "none";
Same here.
}

</script>

<FORM ACTION="url" METHOD="POST">

Show-1: <input type=radio name="name1" onClick="show('div1')">
You should consider

<label for="name1_1">Show-1: </label><input type=radio name="name1"
id="name1_1" onClick="show('div1')">
Hide-1: <input type=radio name="name1" onClick="hide('div1')">

Show-2: <input type=radio name="name2" onClick="show('div2')">
Hide-2: <input type=radio name="name2" onClick="hide('div2')">

</Form>

<div id="div1" style="display:none">
This is message 1.
</div>
Are you aware that without CSS support this will be displayed if
you include it this way? Elements used by client-side scripting
only should be included through it:

document.write('<div>This is message 1.<\/div>');

or

function isMethod(s)
{
if (typeof s == "string")
{
s = eval(s);
}

var t;
return s && (t = typeof s) == "function" || t == "object";
}

var t, o;
if (document.body
&& isMethod("document.body.appendChild")
&& isMethod("document.createElement"))
&& (o = document.createElement("div"))
&& isMethod("o.appendChild")
&& isMethod("document.createTextNode")
&& (t = document.createTextNode("This is message 1.")))
{
o.appendChild(t);
document.appendChild(o);
}

where probably only the latter works in XHTML.
Ed Jay (remove M to respond by email)


| RCPT TO:<ed***@aes-intl.com>
| 550-"The recipient cannot be verified. Please check all recipients of
| this
| 550 message to verify they are valid."

| RCPT TO:<ed**@aes-intl.com>
| 250 Accepted

Forging headers is a violation of Internet Standards and a disregardment
of Netiquette. Ignoring the problem and/or burdening it on others helps
spammers instead of fighting them.

<http://www.interhack.net/pubs/munging-harmful/>
PointedEars
Nov 10 '05 #9
RobG <rg***@iinet.net.au> wrote:
Ed Jay wrote:
>Ed Jay wrote:
>
>>A complete js newbie is asking this question:
>>
>>I have a form comprised of several questions, each answered with a radio
>>button. I'd like to use onClick to bring up additional text at the end of
>>the form (not in a text box)...

Progress. This seems to be working properly, but it also seems much too
simple:

<script language="Javascript">


The language attribute is depreciated, type is required:

<script type="text/javascript">

Thanks.

function show(msg) {
target = document.getElementById(msg);
target.style.display = "";
}

function hide(msg) {
target = document.getElementById(msg);
target.style.display = "none";
}


Why not replace both with a single 'toggle' function and then use a
checkbox (feature testing added also):


'There are 6 questions that all result in the same message and one that
hides it. If I use checks, there's potential ambiguity.
function showHide(cb, id)
{
if (document.getElementById)
var el = document.getElementById(id);

if (el && el.style)
el.style.display = (cb.checked)? '' : 'none';
}
</script>
Show 1? <input type="checkbox" onclick="showHide(this, 'div1')">
Show 2? <input type="checkbox" onclick="showHide(this, 'div2')">
[...]


--
Ed Jay (remove M to respond by email)
Nov 10 '05 #10
Thomas 'PointedEars' Lahn <Po*********@web.de> wrote:
Ed Jay wrote:

Please provide proper attribution, see
<http://jibbering.com/faq/faq_notes/pots1.html>.
vvvvvvvvvvvvvvvvvv
> Ed Jay wrote:
>> A complete js newbie is asking this question:
>>
>> I have a form comprised of several questions, each answered with a
>> radio button. I'd like to use onClick to bring up additional text at
>> the end of the form (not in a text box)...
Progress. This seems to be working properly, but it also seems much too
simple:

<script language="Javascript">


The `language' attribute is deprecated in HTML4, the `type' attribute
is #REQUIRED.
function show(msg) {
target = document.getElementById(msg);
target.style.display = "";


You want to test whether document.getElementById() returned a useful
object reference:

if (target
&& typeof target.style != "undefined"
&& typeof target.style.display != "undefined")
{
target.style.display = "";
}

See also <http://pointedears.de/scripts/dhtml.js>, setStyleProperty().

You probably want to declare the variable with the `var' keyword because
otherwise it becomes global.

That said, it would be more efficient to retrieve the object reference
only once and reuse the variable storing it when needed which may and
may not be achieved using globals.
}

function hide(msg) {
target = document.getElementById(msg);
target.style.display = "none";


Same here.
}

</script>

<FORM ACTION="url" METHOD="POST">

Show-1: <input type=radio name="name1" onClick="show('div1')">


You should consider

<label for="name1_1">Show-1: </label><input type=radio name="name1"
id="name1_1" onClick="show('div1')">
Hide-1: <input type=radio name="name1" onClick="hide('div1')">

Show-2: <input type=radio name="name2" onClick="show('div2')">
Hide-2: <input type=radio name="name2" onClick="hide('div2')">

</Form>

<div id="div1" style="display:none">
This is message 1.
</div>


Are you aware that without CSS support this will be displayed if
you include it this way?


Not a problem.
Elements used by client-side scripting
only should be included through it:

document.write('<div>This is message 1.<\/div>');

or

function isMethod(s)
{
if (typeof s == "string")
{
s = eval(s);
}

var t;
return s && (t = typeof s) == "function" || t == "object";
}

var t, o;
if (document.body
&& isMethod("document.body.appendChild")
&& isMethod("document.createElement"))
&& (o = document.createElement("div"))
&& isMethod("o.appendChild")
&& isMethod("document.createTextNode")
&& (t = document.createTextNode("This is message 1.")))
{
o.appendChild(t);
document.appendChild(o);
}

where probably only the latter works in XHTML.
Ed Jay (remove M to respond by email)


| RCPT TO:<ed***@aes-intl.com>
| 550-"The recipient cannot be verified. Please check all recipients of
| this
| 550 message to verify they are valid."

| RCPT TO:<ed**@aes-intl.com>
| 250 Accepted

Forging headers is a violation of Internet Standards and a disregardment
of Netiquette. Ignoring the problem and/or burdening it on others helps
spammers instead of fighting them.

<http://www.interhack.net/pubs/munging-harmful/>

I appreciate your concern and your suggestions. Thank you.

--
Ed Jay (remove M to respond by email)
Nov 10 '05 #11
Nigel Greenwood wrote:
RobG wrote:

FAQ:
<URL:http://www.jibbering.com/faq/#FAQ4_15>

This is slightly OT, but I wondered about these 2 statements in the FAQ
script:

DocDom = (document.getElementById?true:false);

DocAll = (document.all?true:false);
Why not simply the following?
DocDom = document.getElementById

DocAll = document.all


Why not indeed - it's matter of preference I guess.

The variable name 'DocDom' reminds me of browser sniffing - what is
revealed is not support for DOM but for getElementById, so a better
choice may have been (taking Thomas' hint):

var gebId = !!document.getElementById;
var docAll = !!document.all;
There are other approaches too, such as that suggested in the DynWrite link:

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

<URL:http://www.jibbering.com/faq/faq_notes/alt_dynwrite.html#getEl>

But read the notes - it is not an exact emulation.

Take note of Thomas' point that the existence of a getElementById
property of the document object does not guarantee support for a
W3C-compliant document.getElementById method and that document.all does
not provide a perfect (or perhaps even reasonable) substitute always.

Testing should be designed to reveal whether it is sufficient.
[...]

--
Rob
Nov 10 '05 #12
Thomas 'PointedEars' Lahn said the following on 11/10/2005 6:08 AM:
Ed Jay wrote:

Please provide proper attribution, see
<http://jibbering.com/faq/faq_notes/pots1.html>.
vvvvvvvvvvvvvvvvvv
Yep, the PE I remember is back. Ignore him Jay.

<snip>
Ed Jay (remove M to respond by email)

| RCPT TO:<ed***@aes-intl.com>
| 550-"The recipient cannot be verified. Please check all recipients of
| this
| 550 message to verify they are valid."

| RCPT TO:<ed**@aes-intl.com>
| 250 Accepted

Forging headers is a violation of Internet Standards and a disregardment
of Netiquette. Ignoring the problem and/or burdening it on others helps
spammers instead of fighting them.

<http://www.interhack.net/pubs/munging-harmful/>


More of your BS Thomas. Stick to scripting and leave the common sense to
others.

1) The Header is not forged.
2) It is not helping Spammers, contrary to your warped belief.
3) My email address is valid, but you can't email it. Is that also
helping spammers?
4) The only people who would complain about email addresses not being
valid would be spammers. Are you a spammer?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 10 '05 #13
rf
Thomas 'PointedEars' Lahn wrote:
Please provide proper attribution, see
<http://jibbering.com/faq/faq_notes/pots1.html>. | RCPT TO:<ed***@aes-intl.com>
| 550-"The recipient cannot be verified. Please check all recipients of
| this
| 550 message to verify they are valid."

| RCPT TO:<ed**@aes-intl.com>
| 250 Accepted

Forging headers is a violation of Internet Standards and a disregardment
of Netiquette. Ignoring the problem and/or burdening it on others helps
spammers instead of fighting them.


I let you out of my killfile a month or so ago.
For a while there I thought you were starting to be helpfull. I saw several
good responses to posed questions.

Then you come up yet again with this fucking useless shit!

Who gives a bloody rats smelly fart if a posters email address is valid or
not, especially when the usenet norm is to post back to the group, not the
poster?

Going to complain about mine?

You, pointed ears, are truly a menace to usenet all by yourself.

Now do be a nice chap and fuck off.

--
Cheers
Richard.
Nov 10 '05 #14
Robg, Thomas:

I've incorporated your suggestions to arrive at the following, and it
works just fine. Thank you both very much.

Ed (Remove M to respond by email, that means you too, Thomas) ;-)

ps: Finished product:

<script type="text/javascript">

function show(msg) {
target = document.getElementById(msg);
if (target
&& typeof target.style != "undefined"
&& typeof target.style.display != "undefined")
{
target.style.display = "";
}
}

function hide(msg) {
target = document.getElementById(msg);
if (target
&& typeof target.style != "undefined"
&& typeof target.style.display != "undefined")
{
target.style.display = "none";
}
}

</script>

<Form>
Show-1: <input type=radio name="name1" onClick="show('div1')">
Hide-1: <input type=radio name="name1" onClick="hide('div1')">
<p>
Show-2: <input type=radio name="name2" onClick="show('div2')">
Hide-2: <input type=radio name="name2" onClick="hide('div2')">
<p>
Show-3: <input type=radio name="name3" onClick="show('div3')">
Hide-3: <input type=radio name="name3" onClick="hide('div3')">
</FORM>
<p>

<div id="div1" style="display:none">
This is message 1.
</div>

<div id="div2" style="display:none">
This is message 2.
</div>

<div id="div3" style="display:none">
This is message 3.
</div>

Nov 10 '05 #15
Ed Jay a écrit :
Ed Jay wrote:

>A complete js newbie is asking this question:
>
>I have a form comprised of several questions, each answered with a radio
>button. I'd like to use onClick to bring up additional text at the end of
>the form (not in a text box)...


Progress. This seems to be working properly, but it also seems much too
simple:

<script language="Javascript">


language is deprecated; type is both forward and backward compatible.

function show(msg) {
target = document.getElementById(msg);
You're using a very bad parameter identifier. You should use something
like strId, not msg which is very confusing for you or anyone reading
your code.

target.style.display = "";
}

function hide(msg) {
target = document.getElementById(msg);
target.style.display = "none";
}

</script>

<FORM ACTION="url" METHOD="POST">

Show-1: <input type=radio name="name1" onClick="show('div1')">


Here, we clearly see that your function parameter is an id attribute
value, not a text message of some kind.

Gérard
--
remove blah to email me
Nov 10 '05 #16
Gérard Talbot <ne***********@gtalbot.org> wrote:
Ed Jay a écrit :
>Ed Jay wrote:
>
>>A complete js newbie is asking this question:
>>
>>I have a form comprised of several questions, each answered with a radio
>>button. I'd like to use onClick to bring up additional text at the end of
>>the form (not in a text box)...

Progress. This seems to be working properly, but it also seems much too
simple:

<script language="Javascript">


language is deprecated; type is both forward and backward compatible.

function show(msg) {
target = document.getElementById(msg);


You're using a very bad parameter identifier. You should use something
like strId, not msg which is very confusing for you or anyone reading
your code.

target.style.display = "";
}

function hide(msg) {
target = document.getElementById(msg);
target.style.display = "none";
}

</script>

<FORM ACTION="url" METHOD="POST">

Show-1: <input type=radio name="name1" onClick="show('div1')">


Here, we clearly see that your function parameter is an id attribute
value, not a text message of some kind.

You're point is well made and taken. Thank you.

--
Ed Jay (remove M to respond by email)
Nov 10 '05 #17
Ed Jay a écrit :

[snipped]
function show(msg) {
Ed, I really think you should consider renaming that parameter to
something really meaningful, non-ambiguous. The show function uses a id
attribute to show a div; the show function does not use a message.

A good idea I always use is to prefix the identifiers with the type of
their return value or their type of objects. rdo for radio button, chk
for checkbox, str for string variables, int for integers, etc.

Also, I would personally use a function like/similar to what RobG
suggested where you can toggle display of those div, not to write 2
functions where one show and the other hides. As written, your code is
not optimally performant.

Anyway, you can later examine/study the provided code chuncks and built
your very own function(s) or "play" around these ideas.
target = document.getElementById(msg);
if (target
&& typeof target.style != "undefined"
&& typeof target.style.display != "undefined")
{
target.style.display = "";
}
}

function hide(msg) {
target = document.getElementById(msg);
if (target
&& typeof target.style != "undefined"
&& typeof target.style.display != "undefined")
{
target.style.display = "none";
}
}

</script>

<Form>
Show-1: <input type=radio name="name1" onClick="show('div1')">
Invalid code here. Recommendation:

<form action="">
<p><label>Show-1: <input type="radio" name"rdoDiv1"
onclick="ToggleShowHide('div1');"></label><br>
<label>Hide-1: <input type="radio" name"rdoDiv1"
onclick="ToggleShowHide('div1');"></label></p>

- use of label for accessibility (implicit form here)
- self-explanatory name identifiers
- quoting attribute values; I recommend to always quote attribute values
- action attribute is required
- use of <p> will make the markup code conformant to strict DTD
Hide-1: <input type=radio name="name1" onClick="hide('div1')">
<p>


Gérard
--
remove blah to email me
Nov 10 '05 #18
Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 11/10/2005 6:08 AM:
| RCPT TO:<ed***@aes-intl.com>
| 550-"The recipient cannot be verified. Please check all recipients of
| this
| 550 message to verify they are valid."

| RCPT TO:<ed**@aes-intl.com>
| 250 Accepted

[...]

1) The Header is not forged.


Even you should be able to see that it is (well, maybe not). The mailbox
specified by the From address does not exist, a direct violation of
Internet Standards[1]; the From address that would result in following
the instructions exists. Therefore, the (From) header is definitely
forged.

That may be different in the parallel universe you are posting from,
however it does not change truth in this one. Since you are denying
truth and are merely trolling, I leave you in your fantasy world with
your humble perception of how spamming works, who are the real spammers
and what can be and is to be done against spam.

Fortunately, I have to read your posings only on very rare occasions.
PointedEars
___________
[1] RFC2822[2], section 3.4. Address Specification, esp. paragraph 2
[2] <http://www.rfc-editor.org/rfc/rfc2822.txt>
Nov 10 '05 #19
Gérard Talbot <ne***********@gtalbot.org> wrote:
Ed Jay a écrit :

[snipped]
function show(msg) {
Ed, I really think you should consider renaming that parameter to
something really meaningful, non-ambiguous. The show function uses a id
attribute to show a div; the show function does not use a message.


I think you may have mistaken my previous short response as condescending.
I accepted your suggestion and have changed it from msg to cont_id to
symbolize 'container identifier.'

I should say, though, that the site I'm building is a server-side,
proprietary medical diagnostic application. As such, the more I can
befuddle anyone from cracking the code, the happier I am.
A good idea I always use is to prefix the identifiers with the type of
their return value or their type of objects. rdo for radio button, chk
for checkbox, str for string variables, int for integers, etc.
Good regimen, I agree.
Also, I would personally use a function like/similar to what RobG
suggested where you can toggle display of those div, not to write 2
functions where one show and the other hides. As written, your code is
not optimally performant.
The issue I have with a toggle, which is probably nothing more than a
ramification of my lack of scripting proficiency, is that selecting any of
six buttons results in the same text becoming visible and only one button
to hide it. IOW, if any one of six buttons is checked then show the text,
but if Button 0 is checked, keep it hidden. All of the toggles I've looked
at change state when I select any of the six buttons a second time.
Anyway, you can later examine/study the provided code chuncks and built
your very own function(s) or "play" around these ideas.
target = document.getElementById(msg);
if (target
&& typeof target.style != "undefined"
&& typeof target.style.display != "undefined")
{
target.style.display = "";
}
}

function hide(msg) {
target = document.getElementById(msg);
if (target
&& typeof target.style != "undefined"
&& typeof target.style.display != "undefined")
{
target.style.display = "none";
}
}

</script>

<Form>
Show-1: <input type=radio name="name1" onClick="show('div1')">
Invalid code here. Recommendation:


I don't see what is invalid, other than your adding the <label > tag as
shown, below.
<form action="">
<p><label>Show-1: <input type="radio" name"rdoDiv1"
onclick="ToggleShowHide('div1');"></label><br>
<label>Hide-1: <input type="radio" name"rdoDiv1"
onclick="ToggleShowHide('div1');"></label></p>

- use of label for accessibility (implicit form here)
- self-explanatory name identifiers
- quoting attribute values; I recommend to always quote attribute values
- action attribute is required
- use of <p> will make the markup code conformant to strict DTD
I don't understand why the <label> tag is important.
Hide-1: <input type=radio name="name1" onClick="hide('div1')">
<p>


--
Ed Jay (remove M to respond by email)
Nov 10 '05 #20
rf wrote:
[...]
Going to complain about mine?
[...]


| X-Complaints-To: ab***@bigpond.net.au

[x] done
PointedEars
Nov 10 '05 #21
Thomas 'PointedEars' Lahn <Po*********@web.de> wrote:
Randy Webb wrote:
Thomas 'PointedEars' Lahn said the following on 11/10/2005 6:08 AM:
| RCPT TO:<ed***@aes-intl.com>
| 550-"The recipient cannot be verified. Please check all recipients of
| this
| 550 message to verify they are valid."

| RCPT TO:<
| 250 Accepted

[...]

1) The Header is not forged.


Even you should be able to see that it is (well, maybe not). The mailbox
specified by the From address does not exist, a direct violation of
Internet Standards[1]; the From address that would result in following
the instructions exists. Therefore, the (From) header is definitely
forged.

That may be different in the parallel universe you are posting from,
however it does not change truth in this one. Since you are denying
truth and are merely trolling, I leave you in your fantasy world with
your humble perception of how spamming works, who are the real spammers
and what can be and is to be done against spam.

Fortunately, I have to read your posings only on very rare occasions.

Sir, while I appreciate your concern for spoofing headers, I do it so that
email harvesters won't get my address and send me more of the 500
unsolicited emails sent my way each day. I would really appreciate it if
you don't continue to post my actual address again. Thank you in advance
for your cooperation.

--
Ed Jay (remove M to respond by email)
Nov 10 '05 #22
Ed Jay wrote:
Sir, while I appreciate your concern for spoofing headers, I do it so
that email harvesters won't get my address and send me more of the 500
unsolicited emails sent my way each day.
Don't you think I don't know and understand the reasons why people are
forging headers. However, the means are not always justified by the
result, and since the result here is different from what people expect
from the means used, it is definitely not justified here.

So you chose the simple way, the lazy one. Instead of dealing with spam,
instead of actively or passively fighting spammers (by a honeypot, a
tarpit, notifying admins of open relays etc.), you chose to burden your
problems on other people, as I described. People that maybe want to
communicate with you via private mail (to save the newsgroup from dealing
with off-topic issues), administrators of _receiving_ mail servers that
have to handle the unsolicited error messages they get if a harvested
address is tried aso. You implicitly help spammers to destroy what many
people (and perhaps you) hold most dear: the workings of the Net. And
you do that despite the fact that _easy-to-use_ solutions to handle spam
and to fight spammers exist _for free_.
I would really appreciate it if you don't continue to post my actual
address again. Thank you in advance for your cooperation.


Because of that antisocial behavior, may it be deliberate or not, you do
not have to be afraid that I will post your only (not: "actual") address
here again. Unless you stop that behavior (i.e. post with another address
one can reply-to), this will be my last followup to one of your postings
as my newsreader application will filter them accordingly.
PointedEars
Nov 10 '05 #23
Thomas 'PointedEars' Lahn <Po*********@web.de> wrote:
Ed Jay wrote:
Sir, while I appreciate your concern for spoofing headers, I do it so
that email harvesters won't get my address and send me more of the 500
unsolicited emails sent my way each day.


Don't you think I don't know and understand the reasons why people are
forging headers. However, the means are not always justified by the
result, and since the result here is different from what people expect
from the means used, it is definitely not justified here.

So you chose the simple way, the lazy one. Instead of dealing with spam,
instead of actively or passively fighting spammers (by a honeypot, a
tarpit, notifying admins of open relays etc.), you chose to burden your
problems on other people, as I described. People that maybe want to
communicate with you via private mail (to save the newsgroup from dealing
with off-topic issues), administrators of _receiving_ mail servers that
have to handle the unsolicited error messages they get if a harvested
address is tried aso. You implicitly help spammers to destroy what many
people (and perhaps you) hold most dear: the workings of the Net. And
you do that despite the fact that _easy-to-use_ solutions to handle spam
and to fight spammers exist _for free_.
I would really appreciate it if you don't continue to post my actual
address again. Thank you in advance for your cooperation.


Because of that antisocial behavior, may it be deliberate or not, you do
not have to be afraid that I will post your only (not: "actual") address
here again. Unless you stop that behavior (i.e. post with another address
one can reply-to), this will be my last followup to one of your postings
as my newsreader application will filter them accordingly.

While I greatly appreciated your input to my inquiry, I'm fairly certain I
can live out the rest of my life in your kill-file. Thanks again for your
help, and for your understanding.

BTW, all one has to do to respond to me via email is to follow my request
and delete one letter from my addy. How many letters did it take you to
type the above?

See ya, and thanks again for your assistance.

--
Ed Jay (remove M to respond by email)
Nov 10 '05 #24
rf
Thomas 'PointedEars' Lahn wrote:
rf wrote:
[...]
Going to complain about mine?
[...]


| X-Complaints-To: ab***@bigpond.net.au

[x] done


That would be funny, if it were not so pitiful.

--
Cheers
Richard.
Nov 11 '05 #25
Thomas 'PointedEars' Lahn said the following on 11/10/2005 5:10 PM:
Randy Webb wrote:

Thomas 'PointedEars' Lahn said the following on 11/10/2005 6:08 AM:
| RCPT TO:<ed***@aes-intl.com>
| 550-"The recipient cannot be verified. Please check all recipients of
| this
| 550 message to verify they are valid."

| RCPT TO:<ed**@aes-intl.com>
| 250 Accepted

[...]
1) The Header is not forged.

Even you should be able to see that it is (well, maybe not). The mailbox
specified by the From address does not exist, a direct violation of
Internet Standards[1]; the From address that would result in following
the instructions exists. Therefore, the (From) header is definitely
forged.


forge: to make or imitate falsely especially with intent to defraud

It is not "forged". It is precisely the way it was entered. There is no
attempt to defraud or mislead anyone.
That may be different in the parallel universe you are posting from,
however it does not change truth in this one.
The truth still remains that it is *not* forged. It is precisely the way
it was set, and no intent to defraud or imitate.
Since you are denying truth and are merely trolling, I leave you in your
fantasy world with your humble perception of how spamming works,
Are you really as stupid as you act sometimes Thomas?
who are the real spammers and what can be and is to be done against spam.
The only people I am aware of that want real email addresses are
spammers. You want real addresses only. Whats that mean?
Fortunately, I have to read your posings only on very rare occasions.


You don't have to read them at all. Which would be a good thing. Then, I
could correct your stupidity and wouldn't have to have these endless
arguments with you about it.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 11 '05 #26
Ed Jay said the following on 11/10/2005 6:18 PM:
While I greatly appreciated your input to my inquiry, I'm fairly certain I
can live out the rest of my life in your kill-file. Thanks again for your
help, and for your understanding.


I promise, you are better off not reading his lunatic rantings.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 11 '05 #27
Thomas 'PointedEars' Lahn said the following on 11/10/2005 5:51 PM:
Ed Jay wrote:

Sir, while I appreciate your concern for spoofing headers, I do it so
that email harvesters won't get my address and send me more of the 500
unsolicited emails sent my way each day.

Don't you think I don't know and understand the reasons why people are
forging headers.


Evidently you don't.
However, the means are not always justified by the result, and since the
result here is different from what people expect from the means used, it
is definitely not justified here.
The result is that spammers don't harvest the email address.
The intent is that spammers don't harvest the email address.

The intent and the result match perfectly. So yes, it is very well
justified. Get over, grow up, and move on.
So you chose the simple way, the lazy one.
It is not the lazy one, it is the smartest one.
Instead of dealing with spam, instead of actively or passively fighting
spammers (by a honeypot, a tarpit, notifying admins of open relays etc.),
you chose to burden your problems on other people, as I described.
His solution: Kill spam all together by not giving out the email address.

Your solution: Install more software to fight spam.

Thats stupid on your part.
People that maybe want to communicate with you via private mail (to save
the newsgroup from dealing with off-topic issues),
First, this Usenet. Ask in Usenet, get answered in Usenet. That's the
way it is, and the way it should stay. If you don't like it, nothing
makes you read/post here. And to be quite frank, I don't think anybody
here would miss you.
administrators of _receiving_ mail servers that have to handle the unsolicited
error messages they get if a harvested address is tried aso.
As opposed to those receiving mail servers dealing with spam to legit
addresses? Sheesh get a grip Thomas.
You implicitly help spammers to destroy what many people (and perhaps you)
hold most dear: the workings of the Net.
Bullshit.
And you do that despite the fact that _easy-to-use_ solutions to handle spam
and to fight spammers exist _for free_.


More Bullshit. Simplest way to stop spam? Don't give out the email
address. No spam to deal with. But idiots like you just don't get that.
I would really appreciate it if you don't continue to post my actual
address again. Thank you in advance for your cooperation.

Because of that antisocial behavior, may it be deliberate or not, you do
not have to be afraid that I will post your only (not: "actual") address
here again. Unless you stop that behavior (i.e. post with another address
one can reply-to), this will be my last followup to one of your postings
as my newsreader application will filter them accordingly.


If we could all be that lucky......

Go ahead, killfile me you moron. Like I have already said, all that
means is I wouldn't have to argue with your moronic attitude when I
correct your bullshit.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 11 '05 #28
Ed Jay <ed***@aes-intl.com> wrote:
Ed Jay wrote:
> A complete js newbie is asking this question:
>
> I have a form comprised of several questions, each answered with a radio
> button. I'd like to use onClick to bring up additional text at the end of
> the form (not in a text box)...


Progress. This seems to be working properly, but it also seems much too
simple:


So? There's no rule that says javascript should be cryptic.
what you have is basically all that's needed.
But If you really want to be faulted on it,

recommended:
it's recommended to add <!-- and //--> just inside the <script> tags.
this stops the script from appearing as text on browsers that don't
understand <script>.. also the text tag should be type="text/javascript"
not language=... not that differences changes matter to many..
Totally optional coding style changes:
target should probably have var before it in case you want to use target
as a global var to stop the names clashing. OTOH it's not really needed
here as the result from document.getElementById(msg) is only used once....

you could also do hide/show in a single function by passing 'none' or '' as
a second parameter.

<script type="text/javascript"><!--

function disp(id,dis){
document.getElementById(id).style.display=dis;
}

//--></script>

On the other hand your code is tested and works. my code has not been tested.
bye.



Bye.
Jasen
Nov 11 '05 #29
Jasen Betts said the following on 11/11/2005 4:11 AM:
Ed Jay <ed***@aes-intl.com> wrote:
>Ed Jay wrote:
>
>>A complete js newbie is asking this question:
>>
>>I have a form comprised of several questions, each answered with a radio
>>button. I'd like to use onClick to bring up additional text at the end of
>>the form (not in a text box)...
Progress. This seems to be working properly, but it also seems much too
simple:

So? There's no rule that says javascript should be cryptic.
what you have is basically all that's needed.
But If you really want to be faulted on it,

recommended:
it's recommended to add <!-- and //--> just inside the <script> tags.


Who taught you that nonsense?
this stops the script from appearing as text on browsers that don't
understand <script>.. also the text tag should be type="text/javascript"
not language=... not that differences changes matter to many..
Can you name a browser less than 5 years old that doesn't understand the
script tag and will display the script contents as page text?

Totally optional coding style changes:
target should probably have var before it in case you want to use target
as a global var to stop the names clashing. OTOH it's not really needed
here as the result from document.getElementById(msg) is only used once....
Whether you use var or not does depend on whether you want it global or
not. The preference is to keep as few global variables as possible.
you could also do hide/show in a single function by passing 'none' or '' as
a second parameter.

<script type="text/javascript"><!--

function disp(id,dis){
document.getElementById(id).style.display=dis;


Feature detect. Feature detect. Feature detect.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 23 '05 #30
On 2005-11-11, Randy Webb <Hi************@aol.com> wrote:
Jasen Betts said the following on 11/11/2005 4:11 AM:
it's recommended to add <!-- and //--> just inside the <script> tags.


Who taught you that nonsense?


I don't recall, a trusted source, possibly a book from "SAMS" probably not
a new book.
this stops the script from appearing as text on browsers that don't
understand <script>.. also the text tag should be type="text/javascript"
not language=... not that differences changes matter to many..


Can you name a browser less than 5 years old that doesn't understand the
script tag and will display the script contents as page text?


no. thanks for alerting me
Totally optional coding style changes:
target should probably have var before it in case you want to use target
as a global var to stop the names clashing. OTOH it's not really needed
here as the result from document.getElementById(msg) is only used once....


Whether you use var or not does depend on whether you want it global or
not. The preference is to keep as few global variables as possible.


What I was trying to say was that the variable itself wasn't needed.
you could also do hide/show in a single function by passing 'none' or '' as
a second parameter.

<script type="text/javascript"><!--

function disp(id,dis){
document.getElementById(id).style.display=dis;}


Feature detect. Feature detect. Feature detect.


say what. ???
Bye.
Jasen
Nov 23 '05 #31
Jasen Betts wrote:
On 2005-11-11, Randy Webb <Hi************@aol.com> wrote:
function disp(id,dis){
document.getElementById(id).style.display=dis;}


Feature detect. Feature detect. Feature detect.


say what. ???


You call DOM methods and access host DOM objects without
any prior feature detection which is error-prone.

<http://jibbering.com/faq/#FAQ4_26> pp.
<http://pointedears.de/scripts/test/whatami> pp.
PointedEars
Nov 23 '05 #32
Jasen Betts said the following on 11/12/2005 9:30 PM:
On 2005-11-11, Randy Webb <Hi************@aol.com> wrote:
Jasen Betts said the following on 11/11/2005 4:11 AM:

it's recommended to add <!-- and //--> just inside the <script> tags.
Who taught you that nonsense?

I don't recall, a trusted source, possibly a book from "SAMS" probably not
a new book.


Find a new, better, source. That one has failed you.
this stops the script from appearing as text on browsers that don't
understand <script>.. also the text tag should be type="text/javascript"
not language=... not that differences changes matter to many..


Can you name a browser less than 5 years old that doesn't understand the
script tag and will display the script contents as page text?

no. thanks for alerting me


I would dare say the last 10 years but a browser from the NN2/3 IE3/4
era might bite me for it. But hiding scripts from a browser has been
outdated for a very long time. There are still a few editors that don't
like/recognize script blocks but the sooner they die, the better.
Totally optional coding style changes:
target should probably have var before it in case you want to use target
as a global var to stop the names clashing. OTOH it's not really needed
here as the result from document.getElementById(msg) is only used once....
Whether you use var or not does depend on whether you want it global or
not. The preference is to keep as few global variables as possible.

What I was trying to say was that the variable itself wasn't needed.


True.
you could also do hide/show in a single function by passing 'none' or '' as
a second parameter.

<script type="text/javascript"><!--

function disp(id,dis){
document.getElementById(id).style.display=dis;}


Feature detect. Feature detect. Feature detect.

say what. ???


As Thomas pointed out, you are using getElementById, the style property
and the display property without testing to make sure they exist first.
With the advent of mobile UA devices that may/may not support the
features, it is better to test for them than to cause errors in UA's
that don't support the feature.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 23 '05 #33

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
0
by: Sileesh | last post by:
Hi I have html table and a Button in an Aspx page. I am adding one row with some textboxes to Html table each time i click on the Button thru Javascript. Now problem is when when i try to...
0
by: Luis Esteban Valencia | last post by:
Hello I wrote a program with code behind in C# to add row into table dynamically and the program worked very well in .Net Framework 1.1. When I run this program in .Net Framework 2.0 beta...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
5
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
4
by: Duncan Dimech | last post by:
Dear All I am writing a tool which requires to have controls added to it dynamically. To make the task more complex, the addition of the control cannot happen anywhere but it has to be instead of...
1
by: The Eclectic Electric | last post by:
I'd be very grateful if anyone could help me with this. From my limited knowledge of Javascript I don't think it is possible, but I'll punt anyway. I downloaded and very slightly adapted this...
4
by: Rob Meade | last post by:
Hi all, I played with my first bit of AJAX the other week and was pleasantly surprised that I achieved my goal..now I'd like to try something else.. Question... If I have an updatePanel,...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.