Advertisement

07.08.2008 at 03:00PM PDT, ID: 23548477
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.1

parseInt not working for me

Asked by georgesmay in JavaScript

Tags: ,

I have different scripts working here. The first simple script copy's the form field "price" and pastes it into "total" with an onblur event.

The next script converts the currency over to either dollar, or the Canadian dollar. It fires off with an onchange event when a selection is made.

The problem is when it copies the number over from price it seems to be a string. Therefore the result is NaN. However, if i type the number into the total box and then make a selection it works. I've attached all the code im working with below.  The commented out sections are me testing a few different things.

I've also tried adding parseInt ... However, i dont think im putting it in the right place as im getting the same result.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
The external javascript file
function f36_InitCurrency(f36_ip,f36_sel,f36_ary){
 f36_CIP=document.getElementById(f36_ip);
 f36_Sel=document.getElementById(f36_sel);
 f36_Sel.options.length=0;
 f36_Sel.options[0]=new Option(f36_CIP.value,1,true,true);
 for (f36_0=0;f36_0<f36_ary.length;f36_0++){
  f36_Sel.options[f36_0+1]=new Option(f36_ary[f36_0][0],f36_ary[f36_0][1],true,true);
 }
 f36_Sel.selectedIndex=0;
 f36_Sel.ip=f36_CIP;
 f36_Sel.base=f36_CIP.value;
 f36_Sel.onchange=function(){ f36_Calculate(this); }
 f36_CIP.sel=f36_Sel;
 f36_CIP.onfocus=function(){ f36_Focus(this); }
 f36_CIP.onblur=function(){ this.v=this.value; }
 f36_CIP.onkeyup=function(){ this.value=this.value.replace(/[^0123456789.]/g,''); }
 
}
 
function f36_Focus(obj){
 obj.value='';
 obj.sel.selectedIndex=0;
}
 
function f36_Calculate(f36_obj){
	//f36_obj.ip.v
 if (f36_obj.ip.value.length<1||f36_obj.ip.value==f36_obj.base){ return; }
f36_v=Math.ceil(Number (f36_obj.ip.v)*100*f36_obj.options[f36_obj.selectedIndex].value);
// f36_obj.ip.value=(f36_v/100).toFixed(2);
//f36_v=
f36_obj.ip.value=(f36_v/100).toFixed(2);
 
}
 
/*]]>*/
 
 
 
 
 
The HTML
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<title>George S May International Company</title>
 
<link href="style.css" rel="stylesheet" type="text/css" />
 
<script language="JavaScript" type="text/javascript">
var f36_CAry=new Array();
f36_CAry[0]=['United States',1.0];
f36_CAry[1]=['Canada',.9768];
</script>
 
<script language="javascript" type="text/javascript" src="currency.js"></script>
<script language="JavaScript" type="text/javascript" src="validator.js"></script>
<Script Language="JavaScript">
function fnCopy(){
document.form.x_amount.value = parseInt (document.form.price.value);
}
</Script>
 
<style type="text/css">
<!--
		
	/* classes for validator */
	.tfvHighlight
		{font-weight: bold; color: blue;}
	.tfvNormal
		{font-weight: normal;	color: black;}
 
	.style8 {
	color: #FFFFFF;
	vertical-align: 95%;
	}
	.style9 {
	font-size: 1.5em;
	font-weight: bold;
	}
	.style1 {	font-size: 1.2em;
	font-weight: bold;
	}
	.style10 {
	color: #FF0000;
	font-weight: bold;
	}
	.style12 {font-size: 1.2em}
-->
</style>
 
</head>
 
<body onload="f36_InitCurrency('x_amount','currency',f36_CAry);">
 
 
<div id="header">
  <div align="left"><img src="images/green_logo.gif" /><span class="style8">
    George S May International Company</span></div>
</div>
 
 
<form onsubmit="return v.exec()" name="form"  action="charge.cfm" method="post">
<table width="65%"  border="0" cellpadding="0" cellspacing="1">
  <tr>
    <td colspan="3"><p class="style9">Enter your credit information.</p>
      <p><img src="images/credit_card_logos_10.gif" width="336" height="50" /></p>
      <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td width="18%" height="22" id="t_first_name"><div align="right">First Name<strong>&nbsp;</strong></div></td>
    <td width="38%"><input type="text" name="x_First_Name" size="35" /></td>
    <td width="44%">As it appears on the card</td>
  </tr>
  <tr>
    <td height="25" id="t_last_name"><div align="right">Last Name </div></td>
    <td><span class="style1">
      <input type="text" name="x_Last_Name" size="35" />
    </span></td>
    <td>As it appears on the card</td>
  </tr>
  <tr>
    <td height="25" id="t_card_num"><div align="right">Credit Card Number</div></td>
    <td><span class="style1">
      <input type="text" name="x_card_num" size="35" maxlength="16" />
    </span></td>
    <td>16 Digit number on the front of the card</td>
  </tr>
  <tr>
    <td height="25" id="t_exp_date"><div align="right">Expiration Date</div></td>
    <td><span class="style1">
      <input type="text" name="x_exp_date" size="35" maxlength="4" />
    </span></td>
    <td>(Example : 0910)</td>
  </tr>
  <tr>
    <td height="25" id="t_card_code"><div align="right">CCW Code</div></td>
    <td><span class="style1">
      <input type="text" name="x_card_code" size="35" maxlength="4" />
    </span></td>
    <td>      3 or 4 Digit pin located on the back of the card</td>
  </tr>
  <tr>
    <td id="t_total2" height="25"><div align="right">Price</div></td>
    <td><input type="text"  name="price" onblur="javascript:fnCopy()"/></td>
    <td>Price Charged</td>
  </tr>
  <tr>
    <td id="t_total" height="25"><div align="right"></div></td>
    <td><span class="style1">
      <select name="currency" id="currency">
      </select>
    </span></td>
    <td>Select Currency</td>
  </tr>
  <tr>
    <td height="25" id="t_currency"><div align="right">Total</div>   </td>
    <td colspan="2"><span class="style1">
      <input type="text" name="x_amount" id="x_amount" size="35"/>
      Total
    </span></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="right">
      <input type="reset" value="Reset" name="B2" style="background-image:url(images/button_gradient.jpg)" />
      <input type="submit" value="Submit" name="B1" style="background-image:url(images/button_gradient.jpg)" />
  &nbsp;</div></td>
    <td>&nbsp;</td>
  </tr>
</table>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<script language="JavaScript" type="text/javascript" src="//smarticon.geotrust.com/si.js"></script>
<!-- Validation Code -->
<script language="javascript" type="text/javascript">
// form fields description structure
var a_fields = {
	
	'x_First_Name':{'l':'First Name','r':true,'f':'alpha','t':'t_first_name'},
	'x_Last_Name':{'l':'Last Name','r':true,'f':'alpha','t':'t_last_name'},
	'x_card_num':{'l':'Credit Card Number','r':true,'f':'unsigned','t':'t_card_num'},
	'x_exp_date':{'l':'Expiration Date','r':true,'f':'unsigned','t':'t_exp_date'},
	'x_card_code':{'l':'Card Code','r':true,'f':'unsigned','t':'t_card_code'},
	'currency':{'l':'Currency','r':true,'f':'unsigned','t':'t_currency'},
	'x_amount':{'l':'Total','r':true,'t':'t_total'}
 
	
		
},
 
o_config = {
	'to_disable' : ['Submit', 'Reset'],
	'alert' : 1
}
 
// validator constructor call
var v = new validator('form', a_fields, o_config);
 
</script>
 
</body>
 
</html>
[+][-]07.08.2008 at 09:28PM PDT, ID: 21960614

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 07:18AM PDT, ID: 21963842

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 07:27AM PDT, ID: 21963943

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 07:40AM PDT, ID: 21964102

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 07:45AM PDT, ID: 21964170

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 08:13AM PDT, ID: 21964543

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 08:25AM PDT, ID: 21964706

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 09:33AM PDT, ID: 21965572

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 10:27AM PDT, ID: 21966098

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 11:19AM PDT, ID: 21966636

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 12:16PM PDT, ID: 21967249

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 01:04PM PDT, ID: 21967745

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 01:29PM PDT, ID: 21967992

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 01:43PM PDT, ID: 21968158

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 02:46PM PDT, ID: 21968697

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 09:06AM PDT, ID: 21974816

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 11:32AM PDT, ID: 21976186

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: Javascript, IE 6 Firefox 2
Sign Up Now!
Solution Provided By: HonorGod
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.10.2008 at 11:48AM PDT, ID: 21976308

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 11:58AM PDT, ID: 21976378

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 12:14PM PDT, ID: 21976508

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 12:16PM PDT, ID: 21976519

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 12:40PM PDT, ID: 21976697

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628