/    Sign up×
Community /Pin to ProfileBookmark

What is wrong

This is just a test site for me to mess a round on. All I am trying to do is dynamically fill the “your price” field with a number generate by a simple calculation. “number put into acres” * “1 or 2 depending on the regularity the chose” * “10”. I also add the “$” “per week”. It is really annoying because I had it working yesterday but have no idea why it doesn’t work now. Please help.

Page can be found
[url]http://www.gdarb.com/jj/estimate.html[/url]

Javascript…

[code=html]
function autofill() {
document.estimate.price.value = “$” + document.estimate.acres.value * document.estimate.regularity.value * 10 + ” per week”;
}
[/code]

HTML…

[code=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”>Acres</label>
<input type=”text” name=”acres” id=”acres” value=”” size=”5″ maxlength=”7″ onkeyup=”autofill()” /><br />

<label for=”regularity”>Regularity of Service</label>
<select size=”1″ id=”regularity” name=”regularity” onchange=”autofill()”>
<option value=”1″>Once a week</option>
<option value=”2″>Twice a week</option>
</select><br /><br />

<label for=”price”>Your Price</label>
<input type=”text” name=”price” id=”price” value=”” size=”5″ maxlength=”20″ readonly=”readonly” /><br />
</fieldset>
</form>
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@trielephantJul 17.2007 — Change <form id="estimate" ...> to <form name="estimate" ...>
Copy linkTweet thisAlerts:
@blg002authorJul 17.2007 — I knew it would be something simple. And I know I did it because the name attribute doesn't validate xhmtl strict. I ended up keeping the id="estimate" but changing the js to

[code=html]document.forms['estimate'].price.value[/code]
×

Success!

Help @blg002 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...