Results 1 to 2 of 2

Thread: Javascript calculator form

  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Javascript calculator form

    What I'm trying to create is basically a calculator.
    In excel it works like this: [website link removed]
    The best way would probably be with AJAX, but I'm a javascript beginner.

    So the problem is:
    I have multiple drop-down boxes for input. How do I store values of selected inputs into a single array when I click the submit button?

    Thx in advance!
    Last edited by Alan; 07 Jul 2009 at 12:41 AM.

  2. #2
    Join Date
    Feb 2007
    Location
    Ireland
    Posts
    1,007
    HTML Code:
    <script language="JavaScript">
    function add(val1,val2) {
        var result = val1 + val2;
        document.write(result);
    }
    </script>
    <input type="text" name="value1" value=""/>
    <input type="text" name="value1" value=""/>
    <div onClick="javascript:add(document.value1.value,document.value2.value);">Add</div>
    I assume that's what you mean? Now I haven't actually tested this, so my initial thought would be that it doesn't work because of some syntax error but if so, it's not too far from being correct.
    “The best thing about a boolean is even if you are wrong, you are only off by a bit.”

Similar Threads

  1. Problem with javascript Slideshow and transparent PNG files
    By moez in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 20 Jan 2006, 02:56 PM
  2. element specific javascript
    By gumbo in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 04 Dec 2005, 06:25 PM
  3. element specific javascript
    By gumbo in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 04 Dec 2005, 06:23 PM

Posting Permissions

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