/    Sign up×
Community /Pin to ProfileBookmark

Need help: Multiple drop-downs, extra word charge, running total

Hi everyone. The weekly newspaper I work for wants to take classified ad orders online. I found a script that partially works but am stuck. I have a text field for the ad, a word counter next to it, 3 drop-downs and a text field for the total. I need to add 25-cents per word over 25, add the options from the first 2 drop-downs then multiply that by the number of weeks to run the ad and have it show up in the Total field. If you want to see the page: [url]http://leicesterleader.com/classifieds1.html[/url]

Here’s what I have.

<SCRIPT type=”text/javascript”>

function dp(price) {
return price.toFixed(2);
}

function calculate(info) {
var tmp = [];
tmp = info.split(‘:’);
document.getElementById(tmp[3]).value = dp(tmp[0]*document.getElementById(tmp[2]).value);
document.getElementById(‘subtotal’).value
= dp(Number(document.getElementById(‘total1’).value)+Number(document.getElementById(‘total2’).value));
}
</script>
</head>

<body>

<textarea name=”AdCopy__” rows=”5″ onkeyup=”wordcount(this.value)”></textarea>
<script language=”JavaScript”>
var cnt;
function wordcount(count) {
var words = count.split(/s+/);
cnt = words.length;
var ele = document.getElementById(‘w_count’);
ele.value = cnt;
}
document.write(“<input type=text id=w_count size=4 readonly>”);
</script>

<select name=”price1″ ONCHANGE=”calculate(this.value+’:quantity1:total1′)” id=”Display_options”>
<option value=’0′ selected=”selected”>Select display options</option>
<option value=’1.50?ut a box around my ad for extra $1.50′>Put a box around my ad for extra $1.50</option>
<option value=’2.50?ut a bold box around my ad for extra $2.50′>Put a bold box around my ad for extra $2.50</option>
<option value=’3.00:Make my ad black with white letters for extra $3.00′>Make my ad black with white letters for extra $3.00</option>
</select>
<input type=”hidden” name=”quantity1″ id=”quantity1″ value=”1″ />
<input type=”hidden” id=”total1″ name=”total1″ value=””>

<select name=”price2″ ONCHANGE=”calculate(this.value+’:quantity2:total2′)” id=”Text_options”>
<option value=’0′ selected=”selected”>Select text options</option>
<option value=’1.00:Make text bold for extra $1.00′>Make text bold for extra $1.00</option>
</select>
<input type=”hidden” name=”quantity2″ id=”quantity2″ value=”1″ />
<input type=”hidden” id=”total2″ name=”total2″ value=””>

<select name=”Number_of_Weeks__” id=”Number_of_Weeks__“>
<option selected=”selected”>Select number of weeks to run ad</option>
<option>1 week</option>
<option>2 weeks</option>
<option>3 weeks</option>
<option>4 weeks</option>
<option>5 weeks</option>
<option>6 weeks</option>
</select>

<input type=”text” id=”total” name=”total” value=””>

Thank you for any assistance you can offer.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Smoky_Mtn_Steve 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.2,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...