www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Maths in HTML

  1. #1
    Join Date
    May 2008
    Posts
    9

    Maths in HTML

    Hi All,

    Quick question regarding HTML. Is is possible to use simple mathematical functions such as division within html code?

    I am pulling a variable from a DB that gives me durartion in hours and i want to display it in working days. I.e Divide by 8.

    Is this possible in HTML or would i have to use JS or some server side scripting?

    Thanks in advance,

    M.

  2. #2
    Join Date
    Apr 2008
    Location
    Slovenia
    Posts
    88
    Not possible with only HTML.

  3. #3
    Join Date
    May 2008
    Posts
    9
    Didnt think so, was just chancing my arm to see if any bright sparks out there could show me the light.

    Cheers for the quick response.

    M.

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    There is no Maths in HTML. There is no Arithmetics, nor Algebra, nor Geometry.

    HTML is just a markup language. It transfers and displays some text and picture in a document copied in user's browser and let the user to navigate from a web document to another using the Hyper links capabilities. It migh create, also, interactive forms. That is all.

    What you need is a programming language or at least a scripting language. There are 2 main classes of web programming languages: client-side/scripting (i.e : javascript) and server-side (i.e : php, asp, java, ... and the list is huge here).

    Client side javascript is dynamic and asynchronously, while server-side need the changing of the session.

    So... Which are your needs now?
    Last edited by Kor; 05-09-2008 at 04:44 AM.

  5. #5
    Join Date
    May 2008
    Posts
    9
    Let me give you some more information on what i am trying to achieve here:

    I am creating an email that pulls a figure from a DB and places it in my HTML based email.

    I.e "You worked 400 hours this month." Where the number 400 is pulled from the DB.

    However the figure is in hours and i want to display it in days (i.e divide by 8)

    I tried embedding JS but because Outlook displays emails as HTML the JS is never executed.

    I am about to try it by embedding php into the html but i have a feeling i will get the same result.

    I do not want to change the values in the DB before i pull them.

    Any thoughts?

    M.

  6. #6
    Join Date
    Aug 2007
    Posts
    3,767
    What pulls the information from the database
    Great wit and madness are near allied, and fine a line their bounds divide.

  7. #7
    Join Date
    May 2008
    Posts
    9
    I am using software that has prebuilt namespaces that i can call which are assigned to specific fields in the DB. So as such all that is called in html is something like:

    You have worked #HoursWorked# Hours

    M.

  8. #8
    Join Date
    May 2008
    Posts
    9
    Php didnt work either.....

    M.

  9. #9
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Show us the HTML part of the document

  10. #10
    Join Date
    Apr 2008
    Location
    Slovenia
    Posts
    88
    Does the server you are runing on even support PHP?

  11. #11
    Join Date
    May 2008
    Posts
    9
    ..
    Last edited by Ballochio; 05-09-2008 at 06:18 AM.

  12. #12
    Join Date
    May 2008
    Posts
    9
    Where #ExpectedDuration# returns a number in hours and i want to divide it by 8.

  13. #13
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    FONT is deprecated. use CSS. Give your span an id:
    Code:
    <span id="expDur" style="font-family:Arial;font-size="16px">#Service.ExpectedDuration#</span>
    And in HEAD of the document you may use this javascript piece of code:
    Code:
    <script type="text/javascript">
    onload=function(){
    var txt=document.getElementById('expDur').firstChild;
    txt.nodeValue=txt.NodeValue/8;
    }
    </script>

  14. #14
    Join Date
    May 2008
    Posts
    9
    I tried JS before i posted. It doesnt work because the JS never gets exectuted because emails are sent in pure HTML.

  15. #15
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Oh, I see... It's an E-mail... In this case there is nothing you can do, except for transforming that #Service.ExpectedDuration# at a server level before sending the mail.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles