473,405 Members | 2,262 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,405 software developers and data experts.

Problem...help

Can someone tell me where the problem here is? I can't get the "squared()"
function to work properly...it supposed to put the squared value into the
iframe area.

Thanks,
Ed

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript">
//Square Root
function squareroot()
{
x=document.root
data=x.num.value
var sqr=Math.sqrt(data)
parent.sqrt.document.write(sqr)
}
//Squared of an item
function squared()
{
x=document.square
data=x.num.value
var sum=data*data
parent.squaredframe.document.write()
}
//Tanget
function tangent()
{
x=document.tangent
data=x.num.value
var tan=Math.tan(data)
parent.tangentframe.document.write(tan)
}
//Refresh Values
function refresh()
{
location.reload(sqrt)
location.reload(squaredframe)
location.reload(tangentframe)
}
</script>
</head>

<body>
<table width="100%" border="1">
<tr>
<td width="73%" height="50">
<form name="root">
Type in a number to compute the square root of the value.
<input name="num2" type="text" id="num" size="10" maxlength="10">
<input name="button" type="button" onClick="squareroot()"
value="Compute">
</form></td>
<td width="27%" height="50"><iframe name="sqrt" width="100%" height="50"
frameborder="0" scrolling="no"></iframe></td>
</tr>
<tr>
<td height="50">
<form name="square">
Type in a number to compute the square of the value.
<input name="num3" type="text" id="num2" size="10" maxlength="10">
<input name="button2" type="button" onClick="squared()"
value="Compute">
</form></td>
<td><iframe name="squaredframe" width="100%" height="50" frameborder="0"
scrolling="no"></iframe></td>
</tr>
<tr>
<td height="50">
<form name="tangent">
Type in a number to compute the tanget of the value.
<input name="num" type="text" id="num3" size="10" maxlength="10">
<input name="button3" type="button" onClick="tangent()"
value="Compute">
</form></td>
<td><iframe name="tangentframe" width="100%" height="50" frameborder="0"
scrolling="no"></iframe></td>
</tr>
</table>
<div align="right">
<form name="refresh">
Hit refresh to compute new values.
<input type="button" onClick="refresh()" value="Refresh Values">
</form>
</div>
</body>
</html>

Jul 20 '05 #1
11 1668
Ed Blinn <eb****@sbcglobal.net> writes:
Can someone tell me where the problem here is? I can't get the "squared()"
function to work properly...it supposed to put the squared value into the
iframe area.
Does the other functions work? (No, not in my browsers)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
This DOCTYPE triggers quirks mode. New pages should not be made for
quirks mode.
function squareroot()
{
x=document.root
I prefer
var x = document.forms['root'];
data=x.num.value
and
var data = x.elements['num'].value;

It is much easier to read, and is guaranteed to work in all W3C DOM
browsers too.
var sqr=Math.sqrt(data)
Why make "sqr" a local variable, but not "x" or "data"?
parent.sqrt.document.write(sqr)
The sqrt frame is not a subframe of the parent document, but of this
document (that is why the other functions didn't work for me, I tested
them in an iframe, so "parent" isn't equal to "self").

frames['sqrt'].document.write(sqr);
function squared()
{
x=document.square
data=x.num.value
The form "document.forms['square']" doesn't hae an element called
"num". It has name="num3" and id="num2".

.... <form name="square"> .... <input name="num3" type="text" id="num2" size="10" maxlength="10">


/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
JRS: In article <he**********@hotpop.com>, seen in
news:comp.lang.javascript, Lasse Reichstein Nielsen <lr*@hotpop.com>
posted at Tue, 16 Sep 2003 02:32:17 :-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


This DOCTYPE triggers quirks mode. New pages should not be made for
quirks mode.


What, then, do you recommend?

ISTM that one should choose a <!DOCTYPE ...> (or not to have one), and
then adjust the code until it validates (which involves choosing a
validator).

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #3
Dr John Stockton <sp**@merlyn.demon.co.uk> writes:
This DOCTYPE triggers quirks mode. New pages should not be made for
quirks mode.
What, then, do you recommend?


I recommend deciding on a verions of HTML, in this case version 4.01
Transitional is fine, and the adding a document type declaration for
that version that puts new browsers into standards mode.
That would be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">

If in doubt, add the appropriate URL for the DTD, that always gives
standards mode.

Opera's page about it, with links to MSDN and Mozilla:
<URL:http://www.opera.com/docs/specs/doctype/>
ISTM that one should choose a <!DOCTYPE ...> (or not to have one), and
then adjust the code until it validates (which involves choosing a
validator).


If all the DOCTYPE did was define the HTML version, then you could
probably do without it, as long as you tell the validator what HTML
version to check against.

Since the DOCTYPE declaration does double duty as a trigger for
backwards (or bugwards) compatabilty with pages written directly to
the CSS/rendering bugs of IE 4, new pages should not be written
without a DOCTYPE or with a DOCTYPE that triggers quirks mode.

Ofcourse, I believe in writing to the official standards. Other people
don't care, and will gladly write pages targeted at browsers which can
emulate IE4 (currently includes later IEs, Mozilla and Opera 7, and
maybe others).

These people also live in caves and eat roots (or maybe I am just
channeling Dogbert).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
DU
Lasse Reichstein Nielsen wrote:
Dr John Stockton <sp**@merlyn.demon.co.uk> writes:

This DOCTYPE triggers quirks mode. New pages should not be made for
quirks mode.
What, then, do you recommend?

I recommend deciding on a verions of HTML, in this case version 4.01
Transitional is fine, and the adding a document type declaration for
that version that puts new browsers into standards mode.
That would be:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">

If in doubt, add the appropriate URL for the DTD, that always gives
standards mode.


This will still trigger Safari in backward compatible mode and in
"almost" standards mode in Mozilla. Best is to always use a strict DTD
with full url (case sensitive):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

http://www.hut.fi/u/hsivonen/doctype.html
Opera's page about it, with links to MSDN and Mozilla:
<URL:http://www.opera.com/docs/specs/doctype/>
ISTM that one should choose a <!DOCTYPE ...> (or not to have one), and
then adjust the code until it validates (which involves choosing a
validator).

If all the DOCTYPE did was define the HTML version, then you could
probably do without it, as long as you tell the validator what HTML
version to check against.

Since the DOCTYPE declaration does double duty as a trigger for
backwards (or bugwards) compatabilty with pages written directly to
the CSS/rendering bugs of IE 4, new pages should not be written
without a DOCTYPE or with a DOCTYPE that triggers quirks mode.


I fully, entirely agree with you.

Ofcourse, I believe in writing to the official standards. Other people
don't care, and will gladly write pages targeted at browsers which can
emulate IE4 (currently includes later IEs, Mozilla and Opera 7, and
maybe others).

These people also live in caves and eat roots (or maybe I am just
channeling Dogbert).

/L


DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #5
DU <dr*******@hot-R-E-M-O-V-E-mail.com> writes:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/transitional.dtd">

Should be: "http://www.w3.org/TR/html4/loose.dtd". Doh!
This will still trigger Safari in backward compatible mode
Ick. Do they have to be different from everybody else?
I would expect that to change at some point.
and in "almost" standards mode in Mozilla.
That is acceptable. IIRC, the only difference between standards and
almost-standards in Mozilla is how the line-height of block level
elements affect their inline children.
Best is to always use a strict DTD with full url (case sensitive):


While I prefer to use a strict DTD, some applications need the
Transitional DTD (mainly those involving frames, since the target
attribute does not exist in the strict DTD). I rarely use frames, but
for those who do, I prefer them to use a transitional DTD instead of
no DTD.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6
JRS: In article <he**********@hotpop.com>, seen in
news:comp.lang.javascript, Lasse Reichstein Nielsen <lr*@hotpop.com>
posted at Wed, 17 Sep 2003 13:56:52 :-
DU <dr*******@hot-R-E-M-O-V-E-mail.com> writes:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/transitional.dtd">


Should be: "http://www.w3.org/TR/html4/loose.dtd". Doh!


W3's off-line tester TIDY is equally happy with a sample of my pages
whichever of loose.dtd, transitional.dtd, strict.dtd is invoked. It's
not clear to me whether transitional.dtd exists (I see from <http://www.
hut.fi/u/hsivonen/doctype.html> that xhtml1-transitional.dtd does,
elsewhere), but I assume TIDY is not actually using the line.

I've put datefmts.htm, index.htm, vb-dates.htm, js-date7.htm, and js-
dates.htm as strict.dtd ; <URL:http://www.merlyn.demon.co.uk/js-
date7.htm> is probably the most useful test. Does anyone see problems
with it now using strict.dtd?

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #7
On Wed, 17 Sep 2003 19:02:44 +0100, Dr John Stockton
<sp**@merlyn.demon.co.uk> wrote:
W3's off-line tester TIDY is equally happy with a sample of my pages
whichever of loose.dtd, transitional.dtd, strict.dtd is invoked. It's
not clear to me whether transitional.dtd exists (I see from <http://www.
hut.fi/u/hsivonen/doctype.html> that xhtml1-transitional.dtd does,
elsewhere), but I assume TIDY is not actually using the line.


Why guess? Go to the source.
http://www.w3.org/QA/2002/04/valid-dtd-list.html

There is no transitional.dtd, only loose, strict, and frameset.

I like TIDY for the HTML, but I have terrible problems with it
mangling JavaScript code.

-- Foobus

Quidquid latine dictum sit, altum sonatur.
Jul 20 '05 #8
In article <BB******************@sbcglobal.net>, Ed Blinn <eb****@sbcglobal.net> writes:
Can someone tell me where the problem here is? I can't get the "squared()"
function to work properly...it supposed to put the squared value into the
iframe area.
You don't actually say what happens, but my guess is that this is the
offending line:
parent.squaredframe.document.write()


Shouldn't this document.write have an argument?

--
Michael F. Stemper
#include <Standard_Disclaimer>
Always use apostrophe's and "quotation marks" properly.

Jul 20 '05 #9
JRS: In article <3h********************************@4ax.com>, seen in
news:comp.lang.javascript, Foobus Barrius <de*****@email.invalid> posted
at Thu, 18 Sep 2003 01:55:34 :-

I like TIDY for the HTML, but I have terrible problems with it
mangling JavaScript code.


Perhaps I should make it clear that I only use it as a checker,
preferring to fix faults personally.

Once one knows what it wants, one finds that it only finds typos and
slip-ups to report - and does so usefully often. I test every page
after editing.

You could try the effect of putting your javascript within the despised
<!-- and --> .

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #10
On Fri, 19 Sep 2003 20:20:52 +0100, Dr John Stockton
<jr*@merlyn.demon.co.uk> wrote:


Perhaps I should make it clear that I only use it as a checker,
preferring to fix faults personally.

I agree, but being a mere mortal I occasionally miss one or two. TIDY,
however, manages to find them all, and proceeds to mangle the code
accordingly.
You could try the effect of putting your javascript within the despised
<!-- and --> .


I'm apparently one of the few holdouts that still use those.
Unfortunately, TIDY seems to ignore them at times.
--

Foobus

Quidquid latine dictum sit, altum sonatur.
Jul 20 '05 #11
JRS: In article <co********************************@4ax.com>, seen in
news:comp.lang.javascript, Foobus Barrius <de*****@email.invalid> posted
at Sat, 20 Sep 2003 02:31:15 :-
On Fri, 19 Sep 2003 20:20:52 +0100, Dr John Stockton
<jr*@merlyn.demon.co.uk> wrote:

Perhaps I should make it clear that I only use it as a checker,
preferring to fix faults personally.


I agree, but being a mere mortal I occasionally miss one or two. TIDY,
however, manages to find them all, and proceeds to mangle the code
accordingly.


Since TIDY is an offline checker, I always re-test after fixing faults -
if only to make the list shorter and easier to work from.

It can be worthwhile to look at Tidy's fixes, even if one corrects the
master by hand. As a tester, it told me that someone's – was bad.
As a fixer, it showed me that &ndash; should work, and the browser shows
that it does - also &mdash;.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #12

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

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: Prasanth U | last post by:
Hi All, We are facing a problem while integrating a HTML help file (chm version 1.x) to our windows .net application (C#). The help topic for the controls in the application are shown using the...
16
by: cody | last post by:
I have to write an algorithm with must ensure that objects are put in buckets (which are always 4 in size). The objects have two properties: A and B. It is not allowed that in a bucket are objects...
17
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
11
by: ASP newbie | last post by:
I cannot run my asp.net application in w2k server. But the program works fine under w2k professional. Can anyone tell me is there any difference in the settings? Many thanks.
13
by: Lee Newson | last post by:
Hi, I have just written my first application using VB.NET. The app works fine when i am running it within .NET for debugging purposes, however when i try to run the app from the .exe file that...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
3
by: Rene | last post by:
Hello to all! For a long time I have been "fighting" a problem compiling an OpenGL program which uses GLUT. First I have put a question in a Watcom group (I want to use this compiler) to which I...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
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
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...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.