473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Type Conversion problem when passing through javascript

1
Hi,
I have tried this solution (http://bytes.com/topic/javascript/an...g-numbers-form) for new html file, which works fine, however when I use same code in file where I have several Div's one inside another, it do not call/take the numbers. Please let me know if you if I call the textbox values with reference to form_name or div_name.....


Expand|Select|Wrap|Line Numbers
  1. <body Background ="Images/SoftBlue.jpg"> 
  2. <div id="container">
  3. <form name="umsForm" action="MonthlysalUpdate.php" method="POST">
  4.  <!-- ..................__>
  5. <div id="saldetails">
  6.             <table class="center">
  7.             <tr><td>Earnings :</td><td>Amount</td><td width = "20"></td><td>Deductions</td><td>Amount</td></tr>
  8.  
  9.             <tr><td>Basic :</td><td>        <input type="text" name="basic" onchange="calculate();" value=<?php echo $basic; ?>></td><td width = "20"></td><td>GPF/NPS :</td><td><input type="text" name="basic" value=<?php echo $basic; ?>></td></tr>
  10.  
  11.             <tr><td>Grade Pay :</td><td>    <input type="text" name="grade_pay" onchange="calculate();" value=<?php echo $gpay;?> ></td><td width = "20"></td><td>CGEIS :</td><td><input type="text" name="basic" value=<?php echo $row['ccc'];?>></td></tr>
  12.  
  13.             <tr><td>Special Pay :</td><td>    <input type="text" name="special_pay" onchange="calculate();"  value=<?php echo $special_pay;?> ></td><td width = "20"></td><td>CGHS :</td><td><input type="text" name="basic" value=<?php echo $row['cid'];?>></td></tr>
  14.  
  15. <tr><td>Gross Earnings :</td><td><strong><input type="text" name="gross_earnings" disabled="disabled" value=<?php echo $total; ?> ></strong></td><td width = "20"></td><td>Gorss Deductions :</td><td><strong><input type="text" name="basic" disabled="disabled" value=<?php echo $basic; ?>></strong></td></tr>
  16.  
  17. </div>
  18. </div>
  19. </form>
  20. </body>
  21.  
  22.  
Here is the javascript

Expand|Select|Wrap|Line Numbers
  1. <script>
  2.             function calculate(){
  3.                 alert(document.umsForm.basic.value);
  4.                 document.umsForm.gross_earnings.value = eval(document.umsForm.basic.value) + eval(document.umsForm.gpay.value) + .......;
  5.             }        
  6.         </script>
  7.  
Thanks,
Jag
Jan 27 '12 #1
1 1247
acoder
16,027 Expert Mod 8TB
Do you get an error?

Change eval to parseInt().

PS. split off your question from the thread you posted in (linked to in your post) - please post new questions in a separate thread.
Jan 27 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Faheem Mitha | last post by:
Hi, I'm not sure what would be more appropriate, so I'm ccing it to both alt.comp.lang.learn.c-c++ and comp.lang.python, with followup to alt.comp.lang.learn.c-c++. While working with a...
10
by: Whitney Kew | last post by:
Hello, I have a question regarding type conversion operators. Let's say I have a simple (nonsensical) class as follows: class MakeNewInt { private: int* _n;
1
by: Wolfram Heinz | last post by:
Hi there, How can I avoid type-conversion (object variable --> string) when passing an object variable to a function? Example: --> catch(myerrorobject) alert(myerrorobject.filename); {...
16
by: frs | last post by:
See example below: Why does the output of 'a' work and the output of 'b' fails to compile? Is there a way to write class 'something' so that 'b' converts correctly by default? (include iostream,...
4
by: Mark Oliver | last post by:
Hi, I want to put a type conversion in my class, but I don't want the conversion to be usable in a passed parameter because it makes no sense. class cData { string s; public cData(string s)...
32
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is...
11
by: Kufa | last post by:
Hi, I have a class String which implements the const char*() operator. I was doing some tests today and did something like: String test( "hello world" ); printf( "%s\n", test ); // instead of...
1
by: zaeminkr | last post by:
I have a question about type conversion function for user defined type. I have two classes class DRect { private : double x0; double y0;
4
by: zaeminkr | last post by:
I got a good answer here I have still confusing part. I have two very simple classes class DRect { private : double x0, y0, x1, y1; public : DRect(double a, double b, double c, double d) :...
2
by: java | last post by:
Hi: There is an introductory diagram for those confused by javascript type wrangling (i.e., runtime type conversion by the javascript interpreter). http://mollypages.org/misc/jstypes.mp ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.