473,804 Members | 3,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically total textbox and checkbox

Greetings,

I'm trying to calculate the total on an php page. I'm able to get the
checkbox portion to work properly but I'm having trouble with the
textbox "txtshippin g". The default is 7.95 but if changes I need to
change the total.

How can I make the totalbox the default of the textbox of
"txtshippin g"?

I struggle with javascript so any help would be greatly appreciate.

Thanks in advance.
Bird

<script type="text/javascript">

function gettotal(){

var tmp = 0;
var nBox = document.getEle mentsByName('ch kboxpackage[]');
for(i=1; i<nBox.length+1 ; i++)
{
if (nBox[i-1].checked)
{
tmp += parseFloat(docu ment.forms[0]['hdnPackage'+i].value);

}
}

var nBox2 = document.getEle mentsByName('ch kboxitem[]');
for(i=1; i<nBox2.length+ 1; i++)
{
if (nBox2[i-1].checked)
{
tmp += parseFloat(docu ment.forms[0]['hdnItem'+i].value);

}
}

tmp += parseFloat(docu ment.forms[0]['txtshipping'].value);
document.forms[0].totalbox.value = tmp.toFixed(2);
}

</script>

<input type="checkbox" name="chkboxpac kage[]" value="1"
onClick="gettot al()">
<input type="hidden" name="hdnPackag e1"
value="69.95" >

<input type="checkbox" name="chkboxpac kage[]" value="2"
onClick="gettot al()">
<input type="hidden" name="hdnPackag e2"
value="49.95" >
<input type="checkbox" name="chkboxpac kage[]" value="3"
onClick="gettot al()">
<input type="hidden" name="hdnPackag e3"
value="495.00" >
<input type="checkbox" name="chkboxite m[]" value="1"
onClick="gettot al()">
<input type="hidden" name="hdnItem1"
value="89.95" >
<input type="checkbox" name="chkboxite m[]" value="2"
onClick="gettot al()">
<input type="hidden" name="hdnItem2"
value="99.95" >
<input type="checkbox" name="chkboxite m[]" value="3"
onClick="gettot al()">
<input type="hidden" name="hdnItem3"
value="149.95" >
<input name="txtShippi ng" type="text" size="15"
onChange="getto tal()"></td>
<input type="text" name="totalbox"
value="0.00" readonly/>

Mar 1 '07 #1
1 2062
"bird" <ma******@hughe s.netwrote in
news:11******** *************@p 10g2000cwp.goog legroups.com:
>
How can I make the totalbox the default of the textbox of
"txtshippin g"?
?????? This doesn't make sense. Please explain in different words.
<input name="txtShippi ng" type="text" size="15"
onChange="getto tal()"></td>
?????? You want to calculate the total when the user changes the
shipping cost? Usually the user picks the shipping *method* and the
shipping cost is not in his control. For example, supposed I ordered
something large and heavy from you, and specified the shipping cost as
$1.00. That would be good for me, but bad for you. I suggest you re-
think this part.
Mar 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2263
by: kea | last post by:
I have a checkbox and a textbox in a continuous taborder on a form along with a bunch of other controls. The textbox is disabled. When I leave the checkbox I want to enable the textbox and move the focus to it (only if the checkbox.checked=true). So on the checkbox Leave-event i do the following: if checkbox.checked=true then textbox.enabled = true end if
0
1955
by: Ellen Manning | last post by:
I've got an A2K form with a subform based on a query. This query has a checkbox and an amount field and returns records if checkbox is checked. I Dsum the amount field and display on the main form. If the user unchecks the box, I want the corresponding amount subtracted from the total. If they recheck the box, the amount is to be added. I want all records to appear on the subform even after unchecking them. This works fine...except......
1
4516
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a checkbox and I can't get it to default to checked. I tried radiobuttons and experienced the same result.. can't start them as checked. The really frustrating thing is that I set the attributes of other input controls in the Init() with no problem. ...
4
5056
by: sydney.luu | last post by:
Hello, I would greatly appreciate if someone can show me how to dynamically build a Repeater with unknown number of columns at design time. I have looked various threads in this newsgroup, websites, MSDN and was not able to find something that would help me understand and code. I might not be searching for the right words or phrases. So if you know how to do this or know of links or websites that have information about this, please...
3
2888
by: keithb | last post by:
My code dynamically adds template fields to a GridView control. Everything seems to work OK, except when updating, because I haven't found a way to reference the dynamically added textboxes. FindControl doesn't work, and the textboxes cannot be accessed using grid.Rows.Cells.Control. Can someone help? Thanks, Keith
2
5080
by: sammiesue | last post by:
Hi, I have form with 2 autosummed textboxes ("total" and "casinototal"). I would like to have a grand total textbox ("grandtotal") get its value from summing "total" and "casinototal", but it doesn't seem to be working. Here is my code. Thanks for your help. -sammie <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Nursing Conference 2007 Registration Form</title>
7
4876
by: moksha | last post by:
Hi, I am new to javascript and i am facing a problem in coding. plz help me out. I am using javascript for dynamically creating a table row which contains text boxes and radio buttons and check box. I am adding two radio buttons once for a row.Now my problem is the radio buttons in all the rows that added dynamically are behaving as same group i.e when i am selecting a radio button in second row,radio button in first row...
2
6540
by: ssmith147 | last post by:
Hi, I'm somewhat familiar with access and vb programming (I can read someone else's code, for the most part), but I'm still very green when it comes to creating solutions for my own needs. I'm trying to create a db for a friend's business. I have two issues that I'm wrestling with. First is how to dynamically create a text box on a form. I'm building a form that relates information between two tables (A, B). Table B is the source of...
1
4915
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9588
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
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
10327
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
6857
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
5527
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
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.