SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2008
    Location
    Croatia
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    parseFloat() not returning a float

    I am trying to create a currency converter (in Smarty).
    In my form I have this:
    Code:
    <select id="select1">
    	{foreach from=$currency key=k item=v}
    		<option value={$v}>{$k}</option>
    	{/foreach}
    </select>
    now when i alert out this value:
    Code:
    document.getElementById("select1").value
    I get 7.28575 (or whichever currency is chosen) but when I try to use it in a calculation I get NaN.

    When I add parseFloat to the js and alert it out
    Code:
    parseFloat(document.getElementById("select1").value)
    I get 7

    Anyone know why it is not returning the entire value?

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure that you're not getting 7,28575 ?

    In general, try to isolate your problem and it's often a lot easier to see what's wrong. In this case, the PHP/smarty code is completely orthogonal to your javascript problems.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •