Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 Passing results of this sq ft converter to a form.

View previous topic View next topic Go down 
AuthorMessage
Scars
Member
Member
avatar

Posts : 16
Join date : 2011-03-09

Passing results of this sq ft converter to a form. Empty
PostSubject: Passing results of this sq ft converter to a form.   Passing results of this sq ft converter to a form. EmptyFri Jun 17, 2011 2:25 am

Hi I hope someone can help - Ive been trying to pass the results of this converter to a form on a seporate url - I have looked into this but cant seem to pass a "readonly" Var. Much appreciate any help!!

Also would love to have a 2nd field that would work out a percentage e.g a + VAT.

Hope someone can help, heres the code:

Code:

[
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
#container {
width:290px;
padding:10px;
border:3px double #000;
background-color:#ddd;
font-family:sans-serif;
font-size:0.9em;
color:#000;
margin:30px auto;
}
#container h1 {
font-size:0.9em;
}
.inp {
width:100px;
margin:4px 0;
}
-->
</style>

<script type="text/javascript">
<!--
window.onload=function() {

ppf=1;//price per square foot, edit this to suit

df=document.forms[0];
df[0].focus();
df[2].onclick=function() {
df[0].focus();
}
df[0].onkeyup=function() {
if(isNaN(df[0].value)) {
alert('numbers only please');
df.reset();
df[0].focus();
return;
}
df[1].value='£'+df[0].value*ppf;
}
}
//-->
</script>

</head>
<body>

<form action="#">
<div id="container">

<h1>simple calculator</h1>

<label><input class="inp" type="text"/>: enter square feet</label>
<label><input class="inp" type="text" value="£0" readonly="readonly"/>: total inclusive price</label>
<input type="reset"/>

</div>
</form>

</body>
</html>

]
Back to top Go down
Corverta
Member
Member
avatar

Posts : 20
Join date : 2011-03-09

Passing results of this sq ft converter to a form. Empty
PostSubject: Re: Passing results of this sq ft converter to a form.   Passing results of this sq ft converter to a form. EmptyFri Jun 17, 2011 2:26 am

Why? What is the point? Is this homework?
Back to top Go down
UsernameChange
Staff
Staff
avatar

Posts : 16
Join date : 2011-03-09

Passing results of this sq ft converter to a form. Empty
PostSubject: Re: Passing results of this sq ft converter to a form.   Passing results of this sq ft converter to a form. EmptyFri Jun 17, 2011 2:27 am

I rather think it is!

scars - The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that you are probably looking at ancient and perhaps unreliable code.

window.onload=function() {
That makes no sense! The user has had no time to enter his input!
And you cannot nest functions one within another. You need to completely rework this assignment.
Back to top Go down
Stronger
Member
Member
avatar

Posts : 17
Join date : 2011-03-09

Passing results of this sq ft converter to a form. Empty
PostSubject: Re: Passing results of this sq ft converter to a form.   Passing results of this sq ft converter to a form. EmptyFri Jun 17, 2011 2:28 am

Javiciouse wrote:
window.onload=function() {
That makes no sense! The user has had no time to enter his input!
And you cannot nest functions one within another. You need to completely rework this assignment.

What's wrong with 'window.onload = function() { }' ? The op's code only assigns event handlers.

You can nest functions.. many times. Andy.
Back to top Go down
UsernameChange
Staff
Staff
avatar

Posts : 16
Join date : 2011-03-09

Passing results of this sq ft converter to a form. Empty
PostSubject: Re: Passing results of this sq ft converter to a form.   Passing results of this sq ft converter to a form. EmptyFri Jun 17, 2011 2:30 am

First, there should be a submit button. Second, the input element should have a name

Code:

<label><input class="inp" type="text" value="£0" name='price' readonly="readonly"/>: total inclusive price</label>
<input type="reset"/>
<input type="submit"/>
Back to top Go down
Sponsored content




Passing results of this sq ft converter to a form. Empty
PostSubject: Re: Passing results of this sq ft converter to a form.   Passing results of this sq ft converter to a form. Empty

Back to top Go down
 

Passing results of this sq ft converter to a form.

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» asp.net form
» Validate form
» form validation of a checkbox not quite right
» <div> refresh after form submission - a bug
» AutoFilling an edit form using C#.NET and SQL

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: Passing results of this sq ft converter to a form. Edit-trash Useless :: Trash-