Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,255
Total Threads: 81,257
Total Posts: 567,002
There are 123 users currently browsing (tf).
  Our Partners:
  TalkFreelance     Design and Development     Programming     Javascript :

If, then, else...

Thread title: If, then, else...
    Thread tools Search this thread Display Modes  
06-09-2010, 03:26 PM
Del33t is offline Del33t
Status: I'm new around here
Join date: Jun 2010
Location: Canada
Expertise: Design
Software: Photoshop :)
Posts: 1
iTrader: 0 / 0%

Del33t is on a distinguished road

  Old  If, then, else...

So I'm trying to make this "script" where you are able to input numbers into the form, click the calculate button and with some javascript math it is able to use a formula to output the answer.

The calculations are for a milling machine which uses the formulas as a guide line for operating speeds. The answers are in specified units and the formulas differ depending on if you're using the metric system or imperial system.

Ideally (this is where I need help) there is 2 radio buttons at the top of the form which you can toggle to and from metric and imperial and in turn the formula being used would switch causing the answer to be in either millimeters or inches.

I was wondering if anyone could provide some insight into how I could go about this. My JS knowledge is probably a 0.2 on a scale of 1-10 so any help would be greatly appreciated. What I believe to be the answer is some if,else statements but any other suggestions are welcome. Thanks in advance =/

Hosted online:

Reply With Quote
01-15-2011, 04:50 AM
Morning is offline Morning
Status: Junior Member
Join date: Nov 2010
Location: Alabama, USA
Expertise: web design, writing, proofread
Software: HomeSite, Paint Shop Pro
Posts: 50
iTrader: 0 / 0%

Morning is an unknown quantity at this point


I found one where they did what you're wanting to do. They offer a bit of code to show how:

<div onClick="javascript:ajax_changeUnits();" style="cursor: pointer"><b>
      <span id="uomM" style="color: gray;">METRIC</span> |
      <span id="uomE" style="color: blue;">IMPERIAL</span></b>

You need to enclose your static fields in "ajax-dashboard.php", i.e. fields that don't have an "ajaxtag" which
you want to have converted during UOM switching, with one of the following corresponding <span> classes:
<span class="convTemp">82.7&deg;F</span> ...for temp
<span class="convWind"> 2.7 mph</span> ...for wind
<span class="convBaro">30.30 inHg</span> ...for baro
<span class="convRain"> 1.04 in</span> ...for rain
<span class="convSnow"> 12.4 in</span> ...for snow
<span class="convAlti"> 2793 ft</span> ...for altitude
<span class="convDist"> 15 miles</span> ...for distance
<span class="convDate">20-10-2009</span> ...for dates
<span class="convTime"> 15:32:27</span> ...for times
NOTE: the value in the span must include the units-of-measure for them to be converted.
If you need CSS styling on the same field then you can specify it in the same class tag like this for instance:
<span class="convRain rainStyle">171.4 mm</span>
It seems like you ought to be able to adapt this for what you're trying to do. Hope it helps!

Reply With Quote

Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed