| | |
Adding the values of text boxes (when some text boxes are not called for by PHP)
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2007
Posts: 25
Reputation:
Solved Threads: 0
Adding the values of text boxes (when some text boxes are not called for by PHP)
-1
#1 Oct 4th, 2009
This is my first project using JavaScript.
I have a PHP page that loads text fields "if" called for. I thought JavaScript would be a great way to get the total of all Text Fields without Submit.
The code below is an example of my problem.
If I add to the form, the code works fine.
But again my page dose not always call ALL the Fields in the JS code.
Can anyone help me with this?
Thanks
I have a PHP page that loads text fields "if" called for. I thought JavaScript would be a great way to get the total of all Text Fields without Submit.
The code below is an example of my problem.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<SCRIPT language = JavaScript> function calculate() { A = document.frmOne.txtFirstNumber.value *1 B = document.frmOne.txtSecondNumber.value *1 C = document.frmOne.txtThirdNumber.value *1 D = A + B + C document.frmOne.txtFourthNumber.value = D } </SCRIPT> <FORM NAME = frmOne> Number One: <INPUT TYPE = Text NAME = txtFirstNumber SIZE = 5 value =""> Number Two: <INPUT TYPE = Text NAME = txtSecondNumber SIZE = 5 value =""> <P> Total: <INPUT TYPE = Text NAME = txtFourthNumber SIZE = 5 value = ""> <P> <Input Type = Button NAME = b1 VALUE = "Add Numbers" onClick = calculate()> </FORM>
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<INPUT TYPE = Text NAME = txtThirdNumber SIZE = 5 value ="">
But again my page dose not always call ALL the Fields in the JS code.
Can anyone help me with this?
Thanks
Re: Adding the values of text boxes (when some text boxes are not called for by PHP)
0
#2 Oct 4th, 2009
You have
C = document.frmOne.txtThirdNumber.value *1 in your function so if that field doesn't exist and you try to perform an action on it ( *1 in this case) the function will die. GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: Dec 2007
Posts: 25
Reputation:
Solved Threads: 0
Re: Adding the values of text boxes (when some text boxes are not called for by PHP)
0
#3 Oct 4th, 2009
•
•
Join Date: Dec 2007
Posts: 25
Reputation:
Solved Threads: 0
Re: Adding the values of text boxes (when some text boxes are not called for by PHP)
0
#4 Oct 4th, 2009
I think I got it
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
var C ; if (window.document.frmOne.txtThirdNumber) {C=document.frmOne.txtThirdNumber.value * 1} else {C=0}
![]() |
Similar Threads
- Saving radio button values as text (Visual Basic 4 / 5 / 6)
- adding the values to the grid dynamically and with unique id (ASP.NET)
- Inputting values from a different text file (C++)
- Adding To a list box from multiple text boxes (Visual Basic 4 / 5 / 6)
- Adding values read from input file? (C)
- Adding text boxes and buttons dynamically (JSP)
- How can i add textbox values to listbox values.... (PHP)
- Adding the results of two text boxes (Visual Basic Express Edition) (VB.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: how do i input html files in javascript
- Next Thread: Passing variable from javascript to servlet
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser captcha captchaformproblem cart child class close codes column css date debugger decimal dependent design disablefirebug dom download editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe index java javascript javascripthelp2020 jquery jsf jsp jump libcurl listbox maps masterpage math media menu mp4 object onerror onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming prototype rated rating redirect safari scale scriptlets scroll search security select software star starrating stars synchronous toggle unicode variables w3c web webservice \n






