473,322 Members | 1,379 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,322 software developers and data experts.

Why doesn't this work?! Help!

Can anyone please tell me why this doesn't work?

The sign changes when I hit the button, and I get no error messages, but the
textarea doesn't disappear/reappear.

<html>
<head>
<title>New Page 1</title>
</head>

<body>

<script type=text/javascript>
function openNotepad(valu){
if (valu == "+"){
document.getElementById("NP1").style.visibility="v isible";
document.form.B1.value="-"
}
else {
document.getElementById("NP1").style.visibility="h idden";
document.form.B1.value="+"
}
}
</script>

<form name="form">
<table>
<tr>
<td>
<input name=B1 type=button value=- onclick=openNotepad(this.value)>
</td>
</tr>
<div id="NP1">
<tr>
<td>
<textarea name="texta01" rows=3 cols=40></textarea>
</td>
</tr>
</div>
</table>
</form>
</body>
</html>

Thanks!

iv**@tda.no
Jul 23 '05 #1
3 1654
"Iver Erling Årva" wrote:
Can anyone please tell me why this doesn't work?

The sign changes when I hit the button, and I get no error messages, but the
textarea doesn't disappear/reappear.

<html>
<head>
<title>New Page 1</title>
</head>

<body>

<script type=text/javascript>
function openNotepad(valu){
if (valu == "+"){
document.getElementById("NP1").style.visibility="v isible";
document.form.B1.value="-"
}
else {
document.getElementById("NP1").style.visibility="h idden";
document.form.B1.value="+"
}
}
</script>

<form name="form">
<table>
<tr>
<td>
<input name=B1 type=button value=- onclick=openNotepad(this.value)>
</td>
</tr>
<div id="NP1">
<tr>
<td>
<textarea name="texta01" rows=3 cols=40></textarea>
</td>
</tr>
</div>
</table>
</form>
</body>
</html>

Thanks!

iv**@tda.no


<tr></tr> can't be inside a <div>. The only tags that should appear in
<table></table> are <thead></thead>, <tbody></tbody>, <tfoot></tfoot> and
<tr></tr>.

<tr>
<td><div id="NP1"><textarea name="texta01" ...></textarea></div></td>
</tr>

But you don't need the <div> at all:

function openNotepad(btn) {
var valu = btn.value;
var f = btn.form;
var ta = f.elements['texta01'];

if (ta && ta.style) {

if (valu == "+") {
ta.style.visibility = 'visible';
btn.value = "-";
} else {
ta.style.visibility = 'hidden';
btn.value = "+";
}
}
}

<input type="button" value="-" onclick="openNotepad(this);">

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 23 '05 #2
Ok, thanks! This was just an example. What I really want is to hide and
display entire sections of code. Do I have to enclose the <DIV> tags around
each and every control to achieve that? I have a bit of code I use to hide
the contents of a form until all the dropdowns etc.i.e. the entire page has
been loaded. It is the first statement after the body- and headline tags,
and I then have a function call in the <BODY ONLOAD statement to call a
function that svitches the page contents to visible again. I use this in a
lot of my forms.

<BODY onLoad="setVisible();">

<!-- Page
headline -------------------------------------------------------------------
------------->
<H1 ALIGN="CENTER">ShipAgency - Country Maintenance</H1>

<!-- Use DIV to hide form while loading-->
<DIV ID='MyID' style='visibility:hidden'>

<FORM NAME="form" >
<CENTER>
<TABLE CELLPADDING="2">
<TR>
<TD><SPAN TITLE="Enter a code and hit the <TAB>-key">
<DIV ALIGN="RIGHT"><font size="2">*Country Code:</font></DIV>
</TD>
<td>
and the rest of the form etc.
....
until the end of the page:

</TABLE>
</CENTER>
</FORM>
</DIV>
</BODY>
</HTML>

and then the setVisible function (which is held in the page's <HEAD>
section::

function setVisible()
{
document.getElementById("MyID").style.visibility = "visible";
}

Now, the strange thing is that this works just fine with <TR>s, <TD>s and
whatever I put in there. That is why I didn't understand why the other
example didn't work (and still don't really) (or alternatively don't
understant why the above sample work...).

Confusing!

IV**@tda.no
"Grant Wagner" <gw*****@agricoreunited.com> skrev i melding
news:40***************@agricoreunited.com...
"Iver Erling Årva" wrote:
Can anyone please tell me why this doesn't work?

The sign changes when I hit the button, and I get no error messages, but the textarea doesn't disappear/reappear.

<html>
<head>
<title>New Page 1</title>
</head>

<body>

<script type=text/javascript>
function openNotepad(valu){
if (valu == "+"){
document.getElementById("NP1").style.visibility="v isible";
document.form.B1.value="-"
}
else {
document.getElementById("NP1").style.visibility="h idden";
document.form.B1.value="+"
}
}
</script>

<form name="form">
<table>
<tr>
<td>
<input name=B1 type=button value=- onclick=openNotepad(this.value)> </td>
</tr>
<div id="NP1">
<tr>
<td>
<textarea name="texta01" rows=3 cols=40></textarea>
</td>
</tr>
</div>
</table>
</form>
</body>
</html>

Thanks!

iv**@tda.no
<tr></tr> can't be inside a <div>. The only tags that should appear in
<table></table> are <thead></thead>, <tbody></tbody>, <tfoot></tfoot> and
<tr></tr>.

<tr>
<td><div id="NP1"><textarea name="texta01" ...></textarea></div></td>
</tr>

But you don't need the <div> at all:

function openNotepad(btn) {
var valu = btn.value;
var f = btn.form;
var ta = f.elements['texta01'];

if (ta && ta.style) {

if (valu == "+") {
ta.style.visibility = 'visible';
btn.value = "-";
} else {
ta.style.visibility = 'hidden';
btn.value = "+";
}
}
}

<input type="button" value="-" onclick="openNotepad(this);">

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*

http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html

Jul 23 '05 #3
"Iver Erling Årva" <iv**@tda.no> wrote in message news:<40********@news.broadpark.no>...
Can anyone please tell me why this doesn't work?

The sign changes when I hit the button, and I get no error messages, but the
textarea doesn't disappear/reappear.

<html>
<head>
<title>New Page 1</title>
</head>

<body>

<script type=text/javascript>
function openNotepad(valu){
if (valu == "+"){
document.getElementById("NP1").style.visibility="v isible";
document.form.B1.value="-"
}
else {
document.getElementById("NP1").style.visibility="h idden";
document.form.B1.value="+"
}
}
</script>

<form name="form">
<table>
<tr>
<td>
<input name=B1 type=button value=- onclick=openNotepad(this.value)>
</td>
</tr>
<div id="NP1">
<tr>
<td>
<textarea name="texta01" rows=3 cols=40></textarea>
</td>
</tr>
</div>
</table>
</form>
</body>
</html>

Thanks!

iv**@tda.no


If you name the <TD> element "NP1", instead of the <div> element,
it works... I've experienced troubles sometimes putting <DIV> or
<SPAN> elements in tables.
Jul 23 '05 #4

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

Similar topics

44
by: Mariusz Jedrzejewski | last post by:
Hi, I'll be very grateful if somebody can explain me why my Opera 7.23 (runing under linux) doesn't show me inner tables. Using below code I can see only "inner table 1". There is no problem with...
8
by: Mattias Campe | last post by:
Hello, On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewoners.php?beginAcjaar=2002 when I select...
12
by: Rhino | last post by:
I am having an odd problem: the sqlj command on my system doesn't work. I am running DB2 (LUW) V8 (FP8) on WinXP. I haven't done an sqlj program since Version 6 of DB2 (LUW) so I checked the...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
45
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
10
by: Jarod | last post by:
Hey var service = this.WebServiceURL +"/SessionFun?sessionID="+ this.SessionID ; var xmlDoc=document.implementation.createDocument("", "", null); try {
6
by: Johnny Jörgensen | last post by:
I've got a usercontrol derived from a normal ComboBox that contains some special formatting code. On my main form I've got a lot of my custom comboboxes. I discovered a bug in the derived...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
3
by: NaN | last post by:
Hi I'm using Dev-C++. Here is my sourcecode. /* GETCH.C: This program reads characters from * the keyboard until it receives a 'Y' or 'y'. */ #include <conio.h>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.