SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Location
    Ohio, USA
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need calculator function to return result back to own page

    I need to include a very simple calculator on a page in a joomla client site. Client wants to be able to update rates attached to the calculator and I'm not having them use ftp. Is there a way to insert a small form, have users use the calculator, and have the calculator return the result to the page for the user to see?

    I have an html form on the page. I tried building the calculator in php, then realized I need something client side. So I'm looking at javascript calc functions now. However, I don't know how to get the js to return the result to the page. I'm just beginning my web development/programming career so this is a new aspect for me. Do I use AJAX for this? I've been reading about all this for two days and am getting confused. Do I return the result to an html label? I've not returned a result back to a form before. Any input would be greatly appreciated.

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,283
    Mentioned
    180 Post(s)
    Tagged
    4 Thread(s)
    A quick search of GOOGLE returns a few very useful things like
    this
    this
    this
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Member
    Join Date
    Oct 2011
    Location
    Ohio, USA
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but I need a custom calculator. I'm pretty sure I'll have to write it myself due to the nature of it. I need users to be able to calculate how much water they'll need to fill their swimming pool. This can be done either from their tap, or from a fire hydrant. The rates from the two different sources are different. I've never written javascript, so that's what I've been researching.

    I have a label and one textbox for how many gallons a swimming pool requires. I also have a hidden textbox with the static rate from a user's tap. I have a 'Calculate' button and a 'Clear' button. Of course, the form was easy. I'm struggling with the javascript and how to call it in the form.

  4. #4
    SitePoint Zealot DuncanM's Avatar
    Join Date
    Apr 2005
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One technique I have seen is to use innerHTML.

    On the HTML page on which you want the results output, you define a span and give it a name. In this example, the span is named "output":

    HTML Code:
    <span id="output">
    </span>
    You could even put this span in a table.

    Then, in the Javascript code, once the results have been computed, output the results to this span field by using a statement like the following:

    Code:
    document.getElementById('output').innerHTML = outputString;
    (In this case, the output is a string variable named "outputString".)

  5. #5
    SitePoint Member
    Join Date
    Oct 2011
    Location
    Ohio, USA
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A coworker rewrote this for me in php and it works fine, in WAMP serving up an IE page. Trying to get the php to work in Joomla is another thing. Still working on that. Is there a way to mark this thread solved?


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
  •