Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 29-09-06
Wardy's Avatar
This is the one
 
Join Date: Aug 2003
Posts: 2,747
Thanks: 14
Thanked 0 Times in 0 Posts
Wardy is an unknown quantity at this point
  Adding values of text boxes

I have a coding problem that should be simple to do but I've just gone a blank at the moment.
I have 5 drop down menus and when a user selects a value from it it displays the cost in a text box. So I have 5 drop down menus with 5 text boxes (1 by each drop down).

Anyway, I'm using a javascript bit of code to work out what goes into each text box but I've come to making a "Total" that will be a text box with all the values from the 5 previous text boxes but my mind has gone blank on how to do it

Does this sum have to be done in javascript too or is there a simple PHP way to do it?

The text boxes are named total1, total2...etc

I hope this makes sence

Cheers
Wardy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 29-09-06
Registered User
 
Join Date: Jun 2006
Posts: 177
Thanks: 0
Thanked 1 Time in 1 Post
jonsp is an unknown quantity at this point
this.form.total1.value + this.form.total2.value .......
or
document.forms[0].total1.value + document.forms[0].total2.value...

You'd probably put this in a function and wire it up to onchange on the select.
<script>
function getTotal(f){
f.Total.value = f.total1.value + f.total2.value+f.total3.value + f.total4.value+f.total5.value;
}
</script>
<select onchange="getTotal(this.form);"



Jon

Last edited by jonsp; 29-09-06 at 02:34 PM.. Reason: more info added
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 29-09-06
Registered User
 
Join Date: Mar 2006
Posts: 163
Thanks: 0
Thanked 0 Times in 0 Posts
matty is an unknown quantity at this point
that javascript is for working something out for displaying on the fly.

it can be done in PHP easily, but for that you need to actually communicate with the server by submitting the form values, so not so good if you just want something to automatically update when a field value changes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
LG Chocolate phones2udirect Affiliate Future 1 02-06-06 05:39 PM
LG Chocolate phones2udirect Affiliate Window 1 02-06-06 05:38 PM
CMS / text input boxes morleymouse Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 25-09-05 03:28 PM
Does adding extra text effect tracking Elaine The Affiliate Marketing Lounge 1 14-02-04 12:51 PM
Dell text link will 68 TradeDoubler 2 12-08-03 04:42 AM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7