SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation PHP JavaScript and HTML, seemingly not calling the function.

    Hey everyone,
    This is my firist post, I have been searching for the answer for quite a while and trying many different solutions. I have some java experience but I think I have done something wrong in the code. I'm trying to get the html boxes to update number that is being drawn to the scree when it has been changed. there are 3 boxes that call a function that requires 3 arguments (this is the part I think I'm messing up. Here is the code:
    Code:
    			<div>
    				<label for="buy">Buy Price: <input type="text" name="buy" 
    						id="buy" onchange="solve(this.id,freight.id,markup.id)" value="<?php htmlout($buy); ?>"/></label>
    			</div>
    			<div>
    				<label for="freight">Freight: <input type="text" name="freight"
    						id="freight" onchange="solve(buy.id,this.id,markup.id)" value="<?php htmlout($freight); ?>"/></label>
    			</div>
    			<div>
    				<label for="markup">Markup: <input type="text" name="markup"
    						id="markup" onchange="solve(buy.id,freight.id,this.id)" value="20"/></label>%
    			</div>
    			<div>
            Sell Price: 
    			<script type="text/javascript">
    			function solve(x,y,z)
    			{
    	  	var buy=document.getElementById(x).value;
    			var freight=document.getElementById(y).value;
    			var markup=document.getElementById(z).value;
    			var newmarkup;
    			var sell;
    			var markupamount;
    			sell=buy+freight;
    			newmarkup= "0."+markup;
    			var i = Integer.parseInt(newmarkup.trim());
    			markupamount=sell*i;
    			sell=sell+markupamount;
    			document.write(sell);
    			}
    			</script>
    			</div>
    I believe it should work, but as I said I have only done a little with java and I think I'm messing up somewhere with the arguments.

    Let me know if you need any more information, thanks heaps for any help you guys can offer!
    Last edited by paul_wilkins; Sep 1, 2010 at 18:10. Reason: The scripting language is not Java


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
  •