[Javascript] String -> Number impossible

Roger Roelofs rer at datacompusa.com
Tue Aug 22 06:26:17 CDT 2006


Marcelo,

On Aug 22, 2006, at 12:45 AM, Marcelo Wolfgang wrote:

function getCheckedValue(radioObj) {
   var radioVal = 0;
   for(var i = 0; i < radioObj.length; i++) {
     if(radioObj[i].checked) {
       radioVal parsefloat(radioObj[i].value);
       break;
     }
   }
   return radioVal;
}

function updateTotal(){
   totalField = document.getElementById('valorOnlyNumber');
   totalField.value = 
getCheckedValue(document.frm_calcShipping.valFrete);;
}


> The problem is that rdVal is always a string, I've tried
>
> rdVal = 
> parseFloat('getCheckedValue(document.frm_calcShipping.valFrete)')

Form field values are always strings.  The attempt to turn it into a 
float fails because you put quotes around the getCheckedValue in the 
line above.

hth

-- 
Roger Roelofs
Datacomp Appraisal Services




More information about the Javascript mailing list