473,809 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically fill field with product calculation

1 New Member
All I am trying to do is dynamically fill the "Your Price" field with a number that is the product of the value of "acres" "regularity " and 10. The annoying part is I had it working yesterday and can't figure out what I did to break it.


Link..
http://www.gdarb.com/jj/estimate.html

Javascript...
[HTML]function autofill() {
document.estima te.price.value = "$" + document.estima te.acres.value * document.estima te.regularity.v alue * 10 + " per week";
}[/HTML]


HTML...

[HTML]<script type="text/javascript" src="_js/estimate.js"></script>


<form id="estimate" action="" method="get">
<fieldset>
<legend>Free (Rough) Estimate</legend><br />

<label for="acres">Acr es</label>
<input type="text" name="acres" id="acres" value="" size="5" maxlength="7" onkeyup="autofi ll()" /><br />

<label for="regularity ">Regularit y of Service</label>
<select size="1" id="regularity " name="regularit y" onchange="autof ill()">
<option value="1">Once a week</option>
<option value="2">Twice a week</option>
</select><br /><br />

<label for="price">You r Price</label>
<input type="text" name="price" id="price" value="" size="5" maxlength="20" readonly="reado nly" /><br />
</fieldset>
</form>[/HTML]
Jul 17 '07 #1
4 1856
gits
5,390 Recognized Expert Moderator Expert
hi ...

Expand|Select|Wrap|Line Numbers
  1. document.estimate 
doesn't exist ... i think its a typo ... you have to use:

Expand|Select|Wrap|Line Numbers
  1. document.forms.estimate
or much better, give the fields an id and use:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('field_id').value
kind regards
Jul 17 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
Changed thread title.
Jul 17 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
You already have ids for the fields, so in your autofill(), use:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("price").value = "$" + (document.getElementById("acres").value * document.getElementById("regularity").value * 10) + " per week";
Jul 17 '07 #4
gits
5,390 Recognized Expert Moderator Expert
You already have ids for the fields, so in your autofill(), use:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("price").value = "$" + (document.getElementById("acres").value * document.getElementById("regularity").value * 10) + " per week";
ummm ... i missed to have a closer look ... when someone refers the form.elements-way i always assume in my head that he's not using ids ... ;))

kind regards
Jul 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2112
by: Dave Nouwens | last post by:
Hi All, Please accept my appologies in advance for what I expect will be a reasonably simple question. I have an html form (which is generated in php) which contains a number of rows (one row per product in the 'products' table). It is generated with the following php
2
1605
by: RelaxoRy | last post by:
I have 3 texfield boxes 1. firstname 2. lastname 3. username When a person enters in their firstname and lastname, I want the username field to fill with firstnameLastinitial. Eg. Firstname = Adam, Lastname = Apple, Username = AdamA
5
14549
by: John Sheppard | last post by:
Hi there Does anyone know how to fill a bound textbox automaticlly. In an unbound textbox I would put in the control source =Sum(price, tax) (or some such function) and access updates it automaticlly. Is there a way to do the same thing on a bound textbox so that it is automaticly updated?
7
2186
by: JLM | last post by:
I have a table that has fieldA, fieldB, fieldC. I want fieldC=fieldA-fieldB. simple enough. the next record I want to be able to do the same on the new value of fieldC. I can do this with SAP ABAP/4, but have never done this using Access. I'm sure this can be done, but not sure how to go about it. thanks in advance, jlm
1
2104
by: Dave Stone | last post by:
I find with a table in datasheet view, if a Number field is blank, and I fill it in for a series of rows (more than 2) with values incrementing by 1 or 2 (only), then Access 'helpfully' fills in the field in the 3rd and subsequent rows in turn, incrementing by the 'appropriate' amount. So if Product# is filled in in row 1 as 123, down-arrow to Product# in row 2 and type 125, down-arrow to Product# in row 3, Access has filled in 127. Is...
0
1271
by: tshad | last post by:
MSN has a toolbar that has a Form Fill function that will try to fill form fields on forms when they come up. The problem is that it causes problems with some forms and functions. I found this out this weekend. If you have your address set up in your Form Fill function, any form that has these fields (name, address, city, phone etc) will automatically be filled in. MSN has a toolbar you can download for IE, that is something I am...
1
1344
by: David | last post by:
Hi, I have a table with a field called 'tobuild' This basically holds a figure based on the result of some other stock figures in the same table, 'StockQty' & 'MSQ'. I know you are not supposed to hold a calculated result in a field, but why ?. It works ok for everything in my system, except for when I run this query. MSQ holds the max stock level, StockQty holds the current stock qty and
23
2925
klarae99
by: klarae99 | last post by:
In Access 2003 I am creating an Inventory Database from scratch. There are two tables (tblProductInformation and tblSubProducts) that I am trying to use in a queary to determine the number of Items in Stock. The SubProducts table is linked to the Product Information table by Item # (and the information is added and viewed as a form Product Information with a Sub Form Sub Products) I have a form (frmInventoryLocation) where a location is...
14
3853
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database for inventory control. I am setting up a form (frmProducts) for the viewing and adding of product information. I have several tables that this information is coming from: tblProd with fields: item(PK), CatID(FK), List Price and other not fields not related to this question tblCat with fields: CatID(PK), Category, Tax Rate I have a query:qryListPrice with fields tblProd.ListPrice and...
0
10633
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10375
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,...
0
9198
agi2029
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...
1
7651
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.