Twango Posted January 16, 2010 Share Posted January 16, 2010 Hi, i want to have an html input tag that is used to calculate things etc. i want to make the text string into numbers, how would i do that? Link to comment Share on other sites More sharing options...
boen_robot Posted January 16, 2010 Share Posted January 16, 2010 I suppose you're doing the calculation with JavaScript (since you're posting in this forum)?If so, var fieldValueNum = new Number(fieldValue); is what you need... assuming fieldValue holds the string value of the form field. With the above, fieldValueNum will contain the numeric value of fieldValue, thanks to the Number() object's constructor.Additionally, you may use the parseFloat() and parseInt() functions to convert a value into a float or an integer respectively. Link to comment Share on other sites More sharing options...
Twango Posted January 17, 2010 Author Share Posted January 17, 2010 thanks, one more question, any way to round up to 2 decimals? Link to comment Share on other sites More sharing options...
Synook Posted January 17, 2010 Share Posted January 17, 2010 Times by 100, use Math.ceil(), divide by 100. Link to comment Share on other sites More sharing options...
Twango Posted January 17, 2010 Author Share Posted January 17, 2010 thx, how do i become a mod? Link to comment Share on other sites More sharing options...
ApocalypeX Posted January 17, 2010 Share Posted January 17, 2010 thx, how do i become a mod?loldocument.write("I R M0d") Link to comment Share on other sites More sharing options...
jeffman Posted January 18, 2010 Share Posted January 18, 2010 They start asking you after you've made about 2000 posts without annoying people. thx, how do i become a mod? Link to comment Share on other sites More sharing options...
boen_robot Posted January 18, 2010 Share Posted January 18, 2010 thx, how do i become a mod?And ideally, when you have not asked if you could be a mod. And having that said... you pretty much blew up your chances (at least for the forseeable future) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.