473,549 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(val u){
if (valu == "+"){
document.getEle mentById("NP1") .style.visibili ty="visible";
document.form.B 1.value="-"
}
else {
document.getEle mentById("NP1") .style.visibili ty="hidden";
document.form.B 1.value="+"
}
}
</script>

<form name="form">
<table>
<tr>
<td>
<input name=B1 type=button value=- onclick=openNot epad(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 1669
"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(val u){
if (valu == "+"){
document.getEle mentById("NP1") .style.visibili ty="visible";
document.form.B 1.value="-"
}
else {
document.getEle mentById("NP1") .style.visibili ty="hidden";
document.form.B 1.value="+"
}
}
</script>

<form name="form">
<table>
<tr>
<td>
<input name=B1 type=button value=- onclick=openNot epad(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"><texta rea 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.visibi lity = 'visible';
btn.value = "-";
} else {
ta.style.visibi lity = 'hidden';
btn.value = "+";
}
}
}

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

--
| Grant Wagner <gw*****@agrico reunited.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="setVisi ble();">

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

<!-- Use DIV to hide form while loading-->
<DIV ID='MyID' style='visibili ty: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">*Count ry 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.getEle mentById("MyID" ).style.visibil ity = "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*****@agrico reunited.com> skrev i melding
news:40******** *******@agricor eunited.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(val u){
if (valu == "+"){
document.getEle mentById("NP1") .style.visibili ty="visible";
document.form.B 1.value="-"
}
else {
document.getEle mentById("NP1") .style.visibili ty="hidden";
document.form.B 1.value="+"
}
}
</script>

<form name="form">
<table>
<tr>
<td>
<input name=B1 type=button value=- onclick=openNot epad(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"><texta rea 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.visibi lity = 'visible';
btn.value = "-";
} else {
ta.style.visibi lity = 'hidden';
btn.value = "+";
}
}
}

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

--
| Grant Wagner <gw*****@agrico reunited.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.broadpar k.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(val u){
if (valu == "+"){
document.getEle mentById("NP1") .style.visibili ty="visible";
document.form.B 1.value="-"
}
else {
document.getEle mentById("NP1") .style.visibili ty="hidden";
document.form.B 1.value="+"
}
}
</script>

<form name="form">
<table>
<tr>
<td>
<input name=B1 type=button value=- onclick=openNot epad(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
3834
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 other browsers (I checked it under Konqueror). Thank you in advance for your help. Regards. /Mariusz <HTML>
8
7147
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 2002-03 in the form in the upper right corner (idem dito for the other years). My form is composed by: <form method="post" action="bewoners.php">
12
5320
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 manuals for the proper techniques to prepare an sqlj program. When I went to try the sqlj command, I got this: Exception in thread "main"...
149
25011
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? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
6
13263
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 = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileID.ToString() + ".pdf");
45
4673
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
6542
by: Jarod | last post by:
Hey var service = this.WebServiceURL +"/SessionFun?sessionID="+ this.SessionID ; var xmlDoc=document.implementation.createDocument("", "", null); try {
6
1925
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 control and fixed it. But it still doesn't work for the controls already added to the form. It works fine for new instances of the control dragged from...
39
5830
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 ISO-8859-1 -t UTF-8 mydb.sql mydb_utf8.sql mysqlCREATE DATABASE mydb_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
3
2574
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
7524
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7960
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5089
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
766
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.