Scars Member
Posts : 16 Join date : 2011-03-09
| Subject: Passing results of this sq ft converter to a form. Fri 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>
]
|
|
Corverta Member
Posts : 20 Join date : 2011-03-09
| Subject: Re: Passing results of this sq ft converter to a form. Fri Jun 17, 2011 2:26 am | |
| Why? What is the point? Is this homework? |
|
UsernameChange Staff
Posts : 16 Join date : 2011-03-09
| Subject: Re: Passing results of this sq ft converter to a form. Fri 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. |
|
Stronger Member
Posts : 17 Join date : 2011-03-09
| Subject: Re: Passing results of this sq ft converter to a form. Fri 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. |
|
UsernameChange Staff
Posts : 16 Join date : 2011-03-09
| Subject: Re: Passing results of this sq ft converter to a form. Fri 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"/>
|
|
Sponsored content
| Subject: Re: Passing results of this sq ft converter to a form. | |
| |
|