www.webdeveloper.com
Results 1 to 3 of 3

Thread: Having trouble with script combining form values into a statement.

  1. #1
    Join Date
    Oct 2010
    Posts
    2

    Having trouble with script combining form values into a statement.

    I have the following code which I'm using to calculate the price of a custom order item. The math is working fine.. the problem is simply that I cant get the script to take the form values and apply them to the item_description field. I have another form with fewer fields that is working fine.. I keep going over it and cant figure out why it doesn't work. I am somewhat new to Javascript so am still making stupid mistakes I dont have the experience to troubleshoot at times. Any help is appreciated.






    Code:
    <script>
    function calcField_form1(){
    CalcField.addEquation('form1', 'finishdepth=depth+1.25');
      CalcField.addEquation('form1', 'finishheight=height+1');
      CalcField.addEquation('form1', 'price=(length/12)*(finish+style+12)');
      CalcField.addEquation('form1', 'shipping=(pickup*price*.30)*(1+(zip/60000))');
    }
    calcField_form1();
      </script>
    Code:
    <script src="/accounting.js"></script>
    
    <script type="text/javascript">
    
    
    
    
    
    function money () {
    
    var price      = document.getElementById('price').value;
    
    
    	var pricea = accounting.formatMoney(price);
    				
    				document.getElementById('item_price').value = pricea;
    
    var shipping      = document.getElementById('shipping').value;
    
    	var shipa = accounting.formatMoney(shipping);
    				
    				document.getElementById('item_ship_price').value = shipa;
    
    
    var length      = document.getElementById('length').value;
    var height      = document.getElementById('height').value;
    var depth      = document.getElementById('depth').value;
    var left      = document.getElementById('left').value;
    var right      = document.getElementById('right').value;
    
    var baseheightleft      = document.getElementById('baseheightleft').value;
    
    var basedepthleft      = document.getElementById('basedepthleft').value;
    
    var baseheightright      = document.getElementById('baseheightright').value;
    
    var basedepthright      = document.getElementById('basedepthright').value;
    
    
    var finishing      = document.getElementById('finishing').value;
    var style     = document.getElementById('style').value;
    var bracket      = document.getElementById('bracket').value;
    var finishheight      = document.getElementById('finishheight').value;
    var finishdepth      = document.getElementById('finishdepth').value;
    var notes     = document.getElementById('notes').value;
    var pickup      = document.getElementById('pickup').value;
    
    
    //------------This is where I'm having the problem with the script
    
       document.getElementById('item_description').value = "Custom Baseboard Cover to fit heater " + length + " inches wide, " + height + " inches high and " + depth + " inches deep.  Overall dimensions of cover will be "  + finishheight + " inches high, " + finishdepth + " inches deep.  Cover will have a baseboard cutout " + baseheightleft + " inches high by " + basedepthleft + " inches deep on the left and " + baseheightright + " inches high by " + basedepthright + " inches deep on the right. On the left side " + left + ". On the right side " + right + ". Cover will be sent " + finishing + ". Cover will have " + style + ". Cover will: " + bracket + " Your cover " + pickup + ".  Additional notes you provided: " + notes;
    
    }
    
    	
    </script>


    <input type="submit" value="Add To Cart" name="B1" onclick="return money();"/></p>

    </form>[/HTML]

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,443
    Can you show the HTML, CSS and JS together?
    It would make it a lot easier to test and/or debug.
    Do you have a live site to look at?

  3. #3
    Join Date
    Jan 2013
    Posts
    7
    You need to change the following:

    Code:
    document.getElementById('item_description').value
    to:

    Code:
    document.getElementById('item_description').innerHTML
    I'm a beginner too, so if I'm wrong, somebody experienced jump in and stop me!!

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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