Can someone tell me why this script will only work on a Mac with Internet
Explorer.
Thanks,
Ed
<html>
<head>
<script type="text/javascript">
//Square Root
function squareroot()
{
var x=document.form s('root')
var data=x.elements['num'].value;
var sqr=Math.sqrt(d ata)
frames['sqrt'].document.write (sqr)
}
//Squared of an item
function squared()
{
var x=document.form s('square')
var data=x.elements['num2'].value;
var sum=data*data
frames['squaredframe'].document.write (sum)
}
//Tanget
function tangent()
{
var x=document.form s('tangent')
var data=x.elements['num3'].value;
var tan=Math.tan(da ta)
frames['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="num" type="text" id="num" size="10" maxlength="10">
<input name="button" type="button" onClick="square root()"
value="Compute" >
</form></td>
<td width="27%" height="50"><if rame 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="num2" type="text" id="num2" size="10" maxlength="10">
<input name="button2" type="button" onClick="square d()"
value="Compute" >
</form></td>
<td><iframe name="squaredfr ame" 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="num3" type="text" id="num3" size="10" maxlength="10">
<input name="button3" type="button" onClick="tangen t()"
value="Compute" >
</form></td>
<td><iframe name="tangentfr ame" 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="refres h()" value="Refresh Values">
</form>
</div>
</body>
</html> 1 2087
Ed Blinn wrote: Can someone tell me why this script will only work on a Mac with Internet Explorer.
Thanks, Ed
<html>
No doctype declaration. http://www.hut.fi/u/hsivonen/doctype.html http://www.w3.org/QA/2002/04/valid-dtd-list.html
<head> <script type="text/javascript"> //Square Root function squareroot() { var x=document.form s('root')
1- When editing any kind of code in any language, try to use meaningful,
intuitive, significant identifier names for variables. This is a good
coding practice which saves time to others reviewing your code, help
debugging with debuggers, etc..
2- forms["root"] is correct. forms[0] is even better since it will work
flawlessly in HTML strict DTD and XHTML strict DTD. forms('root') won't
work.
Together:
var objForm = document.forms["root"];
var data=x.elements['num'].value;
W3C DOM methods prefer
elements.namedI tem("num").valu e http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-76728479 http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-75708506 http://www.w3.org/TR/DOM-Level-2-HTM...tion-namedItem
var sqr=Math.sqrt(d ata)
If data is a string, then calling Math.sqrt will not work... and num is
type="text" http://devedge.netscape.com/library/...h.html#1197825
frames['sqrt'].document.write (sqr)
You must first open the iframed document, then write sqr, then close the
iframed document.
So:
frames["sqrt"].document.open( );
"open:
Open a document stream for writing. If a document exists in the
target, this method clears it." http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-72161170
frames["sqrt"].document.write (sqr);
frames["sqrt"].document.close ();
"close:
Closes a document stream opened by open() and forces rendering." http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-98948567
IMO, there is nothing, absolutely nothing which justifies the use of
iframes for the apparent purposes of your code.
} //Squared of an item function squared() { var x=document.form s('square')
var objFormSquare = document.forms["square"];
var data=x.elements['num2'].value;
var data = parseFloat(objF ormSquare.eleme nts.namedItem(" num2").value);
var sum=data*data frames['squaredframe'].document.write (sum)
open and close here too.
} //Tanget function tangent() { var x=document.form s('tangent')
forms["FormName"] or forms[index]
var data=x.elements['num3'].value; var tan=Math.tan(da ta)
Again here too: parseFloat before calculating the tan.
The parameter must be a number. http://devedge.netscape.com/library/...h.html#1194346
frames['tangentframe'].document.write (tan) } //Refresh Values function refresh() { location.reload (sqrt)
frames["sqrt"].location.reloa d(true);
would be the correct way to force a reload but since you would open()
and then close() the iframe, then reloading the iframed document is no
longer necessary.
location.reload (squaredframe) location.reload (tangentframe) } </script> </head>
<body> <table width="100%" border="1">
table design: avoid this whenever you can. Tables should be used only
for tabular data.
<tr> <td width="73%" height="50"> <form name="root">
A table can be inside a form; the opposite creates invalid documents.
Here, the action attribute is missing. A validator would have reported
this as an error.
Type in a number to compute the square root of the value. <input name="num" type="text" id="num" size="10" maxlength="10">
For several reasons which I won,t explicit here, I recommend to always
give distinct identifier values to name attribute and id attribute. If
you don't need to declare an id attribute, then don't.
<input name="button" type="button" onClick="square root()" value="Compute" > </form></td> <td width="27%" height="50"><if rame name="sqrt" width="100%" height="50" frameborder="0" scrolling="no"> </iframe></td> </tr> <tr> <td height="50"> <form name="square">
same thing here: you can not have a form inside a table. Action missing.
Type in a number to compute the square of the value. <input name="num2" type="text" id="num2" size="10" maxlength="10"> <input name="button2" type="button" onClick="square d()" value="Compute" > </form></td> <td><iframe name="squaredfr ame" width="100%" height="50" frameborder="0" scrolling="no"> </iframe></td> </tr> <tr> <td height="50"> <form name="tangent">
action missing; form can not be within a table.
Type in a number to compute the tanget of the value. <input name="num3" type="text" id="num3" size="10" maxlength="10"> <input name="button3" type="button" onClick="tangen t()" value="Compute" > </form></td> <td><iframe name="tangentfr ame" 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="refres h()" value="Refresh Values"> </form> </div> </body> </html>
3 forms, 3 iframes, reload/refresh functions can be reduced to, replaced
by a single form.
Tested, valid and working in MSIE 6 for Windows, Opera 7.20, Mozilla
1.5b and NS 7.1: http://www10.brinkster.com/doctorunc...culations.html
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Marc |
last post by:
Hi all,
I was using Tkinter.IntVar() to store values from a large list of
parts that I pulled from a list. This is the code to initialize the
instances:
def initVariables(self):
self.e = IntVar()
for part, list in info.masterList.items():
|
by: fis |
last post by:
Hi all,
I've problem because there are needed break lines in my texts on the
web site but i can't do it :(
My pipeline looks like: XMS -> I18N -> XSLT -> HTML
I have lot of texts in my "languages" files and these are describes
for things on my website.
Example text looks like this:
|
by: Nafai |
last post by:
Hello. I want to do something like this:
class A { // It's virtual
protected:
float* data;
int n;
public:
A(int a);
virtual float* createData();
//...
|
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 part of Manager is copied. "....
and gives the code above as
.....
|
by: umhlali |
last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem serializing the object but there seems to be a problem serializing an array of objects. Any help will be appreciated
"Cannot assign object of type System.Object to an object of type ElectronicWallet.C2PTest.PaymentItem."
:...
| |
by: caldera |
last post by:
hi,
I have a debug problem. I divide my web project into two part actually two
project. One part is include the all of the logic class and other part web
application part. These are two different projects. I add the dll of the
first part to web part as a references. But then I can't debug the first
part while I run the web part. It said that "The breakpoint will not
currently be hit.No symbols have been loaded for this document". But web...
|
by: Siv |
last post by:
Hi,
I seem to be having a problem with a DataAdapter against an Access database.
My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable.
I then proceed to update a list to reflect that the 3 items have been
deleted only to discover that the 3 items appear, however when I click on
them to display their information which runs a datareader over the same
database it appears that the data has now gone.
I wondered whether...
|
by: yqlu |
last post by:
I hava developed a client in C# that is connected to a 3-party XML Web
Services developed in Java based on the AXIS 1.1. Most methods call are
successful except for one method named "findObjects" and return a complex
type "FieldSearchResult". The error message as following :
"Cannot assign object of type System.String to an object of type
System.String. There is an error in XML document (23, 97)."
By the way,I hava written a client in Java...
|
by: leslie_tighe |
last post by:
Hello,
I have webservice created with Axis 1.2.1 and that I am trying to
consuming in .NET (VB) using the Microsoft provided tools. While I am
able to consume methods on the service that return simple type, I
cannot consume methods that return complex objects. I have tried
experimenting, with this, but am at a bit of loss on where the problem
lies. When I call the services from a browser, I do get back the
response that contains valid...
|
by: leslie_tighe |
last post by:
Hello,
I have a webservice running on a J2EE server created with Axis 1.2.. I
have a client that I am building in .net that needs to consume this
webserivce and am having a bit of trouble. I have pasted the wsdl
below and have a created a class in VB.net by adding a web refrence to
my project. What is odd is that I can successfully call methods that
return a simple value like a string. I call also call methods that add
an object....
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |