Jump to content


javascript problem


2 replies to this topic

#1 niurexx

    Young Padawan

  • Members
  • Pip
  • 7 posts

Posted 06 December 2008 - 12:53 AM

i got a prob to run this code with firefox but it run smooth in internet explorer... here i put some screenshot.

using firefox

Posted Image


using internet explorer

Posted Image

and i attached my source code

<script type="text/javascript" language="c#">
function roundTo2D(n) { 

  ans = (Math.round(n * 100))/100 + "" 
  dot = ans.indexOf(".",0) 
  if (dot == -1) {ans = ans + ".00"} 
  else if (dot == ans.length - 2) {ans = ans + "0"} 
  return ans 
} 


function addptitle(){
var sel=document.getElementById("producttitle").value;
	if(sel==1){
	document.getElementById("newtitle").style.display="block";
	}else{
	document.getElementById("newtitle").style.display="none";
	}
}
function addsubtitle(){
var sel=document.getElementById("subtitle").value;
	if(sel==1){
	document.getElementById("newsubtitle").style.display="block";
	}else{
	document.getElementById("newsubtitle").style.display="none";
	}
}
function addprincipal(){
var sel=document.getElementById("principal").value;
	if(sel==1){
	document.getElementById("newprincipal").style.display="block";
	}else{
	document.getElementById("newprincipal").style.display="none";
	}
}
function AddNewItem(){
var sel=document.getElementById("SEL1").value;
	if(sel==2){
	document.getElementById("product").style.display="block";
	document.getElementById("box").style.display="none";	
	}else{
	document.getElementById("box").style.display="block";
	}
}

function productlist(){
var sel=document.getElementById("product").value;
	if(sel==1){
	document.getElementById("addproduct").style.display="none";
	}else{
	document.getElementById("addproduct").style.display="block";
	}
}

function addnewpro(){
	document.getElementById("bgaddproduct").style.display="block";
	document.getElementById("product2").style.display="block";
	document.getElementById("addproduct").style.display="block";	
}
function ShowOtherTax(){
document.getElementById("othtaxtr").style.display="block";
}

var taxCount = 1;

function createNewTax(){
taxCount++;
var newtr = document.getElementById('taxinfotr1').cloneNode(true);
newtr.getElementsByTagName('input')[0].id="taxdesc" + taxCount;
newtr.getElementsByTagName('input')[0].name="taxdesc" + taxCount;
newtr.getElementsByTagName('input')[0].value="";
newtr.getElementsByTagName('input')[1].id="taxpercent" + taxCount;
newtr.getElementsByTagName('input')[1].name="taxpercent" + taxCount;
newtr.getElementsByTagName('input')[1].value="";
newtr.getElementsByTagName('input')[2].id="taxamount" + taxCount;
newtr.getElementsByTagName('input')[2].name="taxamount" + taxCount;
newtr.getElementsByTagName('input')[2].value="";
newtr.id="taxinfo" + taxCount; 
document.getElementById('othertaxtb').lastChild.appendChild(newtr);

var lasttaxtr = document.getElementById('lasttaxtr');
document.getElementById('othertaxtb').lastChild.appendChild(lasttaxtr);
}

function CalTotalOtherTax(){
 var principalprice = document.form1.principalprice.value;
 var totalothertax = 0.00;
 for (var i=1; i<=taxCount; i++ ){
 var taxpercentid = "taxpercent"+i;
 var taxpercent = document.getElementById(taxpercentid).value;
 var taxamountid = "taxamount"+i;
 var taxamount = eval(taxpercent) * eval(principalprice)/100;
	if (principalprice){
	 document.getElementById(taxamountid).value=taxamount;
	 totalothertax = totalothertax + taxamount;
	}
 }
 
 document.form1.totalothertax.value=totalothertax;
	if (principalprice){
	CalculateFromPrice();
	}
}

function CalculateFromPrice(){
	var principalprice = document.form1.principalprice.value;
	var commpercent = document.form1.commpercent.value;
	var commamount = document.form1.commamount.value;
	
	document.form1.principalprice.value = roundTo2D(principalprice);

	if (!commpercent)commpercent = 20;
	commamount = eval(principalprice * commpercent /100);
	document.form1.commpercent.value = commpercent;
	document.form1.commamount.value = roundTo2D(commamount);

	var markuppercent = document.form1.markuppercent.value;
	var markupamount = document.form1.markupamount.value;
	
	if (!markuppercent)markuppercent = 0.00;
	
	markupamount = eval(principalprice * markuppercent /100);
	var whtpercent = 10;
	whtamount = principalprice * eval(whtpercent) /100; 
	document.form1.whtamount.value = roundTo2D(whtamount);
	document.form1.markuppercent.value = markuppercent;
	document.form1.markupamount.value = roundTo2D(markupamount);

	var totalothertax = document.form1.totalothertax.value;
	 if (!totalothertax) {
	 totalothertax = 0.00;
	 }else{
		 var totalothertax = 0.00;
		 for (var i=1; i<=taxCount; i++ ){
		 var taxpercentid = "taxpercent"+i;
		 var taxpercent = document.getElementById(taxpercentid).value;
		 var taxamountid = "taxamount"+i;
		 var taxamount = eval(taxpercent) * eval(principalprice)/100;
			if (principalprice){
			 document.getElementById(taxamountid).value=taxamount;
			 totalothertax = totalothertax + taxamount;
			}
		 }
		 
		 document.form1.totalothertax.value=totalothertax;
	 }
		
	var profitperproduct = eval(markupamount) + eval(commamount);
	document.form1.profitperproduct.value = roundTo2D(profitperproduct);
	var calcprice = eval(principalprice) + eval(markupamount) + eval(whtamount) + eval(totalothertax);
	document.form1.calcprice.value = roundTo2D(calcprice);
	document.form1.commonprice.value = roundTo2D(calcprice);
	
}

function UpdateFromCommPercent(){
var principalprice = document.form1.principalprice.value;
var commpercent = document.form1.commpercent.value;
 	if (commpercent>100){
	alert("Commission percentage must not more than 100%");
	document.form1.commpercent.value='100';
	}
	
	if (principalprice){
	CalculateFromPrice();
	}
}

function UpdateFromCommAmount(){
var commamount = document.form1.commamount.value;
var principalprice = document.form1.principalprice.value;

	if (principalprice){
		if (eval(commamount)>=eval(principalprice)){
		alert("Commission amount must not exceed "+principalprice+"USD");
		commamount=principalprice;
		}
	var commpercent = eval(commamount)/eval(principalprice)*100;
	document.form1.commpercent.value = commpercent;
	CalculateFromPrice();
	}
}


function UpdateFromMarkuppercent(){
var principalprice = document.form1.principalprice.value;
var markuppercent = document.form1.markuppercent.value;
	if (principalprice){
	CalculateFromPrice();
	}
}

function UpdateFromMarkupamount(){
var markupamount = document.form1.markupamount.value;
var principalprice = document.form1.principalprice.value;
	if (principalprice){
	var markuppercent = eval(markupamount)/eval(principalprice)*100;
	document.form1.markuppercent.value = markuppercent;
	CalculateFromPrice();
	}
}

</script>
<form id="form1" name="form1" method="post" action="product_av_detail.php">
<table width="686" align="center" cellpadding="3" cellspacing="2">
  <tr class="row2">
	<td colspan="2"><span class="red">New Product </span></td>
  </tr>
  <tr class="row2">
	<td width="160" class="text">Part Number </td>
	<td class="text"><input name="textfield" type="text" size="30" /></td>
  </tr>
  <tr class="row2">
	<td width="160" class="text">Product Name </td>
	<td class="text"><input name="textfield6" type="text" size="50" /></td>
  </tr>
  <tr class="row2">
	<td width="160" class="text">Product Title</td>
	<td class="text"><select name="producttitle" id="producttitle" size="1" onchange="addptitle();">
	  <option>Patches</option>
	  <option>Bridge Plugs</option>
	  <option>Cement Dump Bailer</option>
	  <option>Thru Tubing Bridge Plugs</option>
	  <option class="blueadd" value="1">--Add New--</option>
	  <option selected="selected">--Please Choose--</option>
	</select>	</td>
  </tr>
  <tr class="row2" id="newtitle" style="display:none">
	<td width="160" class="bgboxtitle"> New Product Title</td>
	<td class="bgboxtitle"><input name="textfield8" type="text" size="50" /></td>
  </tr>
  <tr class="row2">
	<td width="160" class="text">Product Sub-Title</td>
	<td class="text"><select name="subtitle" size="1" id="subtitle" onchange="addsubtitle();">
	  <option>New Stackable 2 7/8&quot; Componants</option>
	  <option>3 1/2&rdquo; 9.2# GTX-Span Tubing Patch</option>
	  <option>3 1/2&rdquo; 9.2# X-Span Tubing Patch Chrome</option>
	  <option>5 1/2&rdquo; GTX-Span</option>
	  <option>7&rdquo; Generic X-Span Casing Patch</option>
	  <option class="blueadd" value="1">--Add New--</option>
	  <option selected="selected">--Please Choose--</option>
	</select>	</td>
  </tr>
  <tr class="row2" id="newsubtitle" style="display:none">
	<td width="160" class="bgboxtitle"> New Product Sub-Title</td>
	<td class="bgboxtitle"><input name="textfield9" type="text" size="50" />	</td>
  </tr>
  <tr class="row2">
	<td width="160">Principal Price  (USD) </td>
	<td><input name="principalprice" type="text" class="alignright" id="principalprice" onblur="CalculateFromPrice();" />	</td>
  </tr>
  <tr class="row2">
	<td>Commission to Neural  (USD) </td>
	<td><input name="commpercent" type="text" class="alignright" id="commpercent" onblur="UpdateFromCommPercent();" />	  %  &nbsp;&nbsp;
	  <input name="commamount" type="text" class="alignright" id="commamount" onblur="UpdateFromCommAmount();" /> 
	  (USD) </td>
  </tr>
  <tr class="row2">
	<td width="160">Extra Mark Up Amount </td>
	<td><input name="markuppercent" type="text" class="alignright" id="markuppercent" onblur="UpdateFromMarkuppercent();" />
	%&nbsp;&nbsp;&nbsp;
	  <input name="markupamount" type="text" class="alignright" id="markupamount" onblur="UpdateFromMarkupamount();" /> 
	  (USD) </td>
  </tr>
  <tr class="row2">
	<td width="160">With Holding Tax (WHT) 
	<br />
	  <br />
	  <span class="addnew" onclick="ShowOtherTax();" style="cursor:pointer">add other tax</span>	</td>
	<td><input name="whtamount" type="text" disabled="disabled" class="alignright" id="whtamount" /> 
	(USD) </td>
  </tr>
  <tr class="row2" id="othtaxtr" style="display:none">
	<td>Other Taxes (USD) <br><br><a onclick="createNewTax();" style="cursor:pointer">Add New Tax</a></td>
	<td>
	<table width="100&" cellpadding="3" cellspacing="2" class="group" id="othertaxtb" style="display:block">
	  <tr class=header>
		<td align="center" class="bgcomptitle">Description</td>
		<td align="center" class="bgcomptitle">% </td>
		<td align="center" class="bgcomptitle">Amount (USD) </td>
	  </tr>
	  <tr id="taxinfotr1">
		<td><input name="taxdesc1" type="text" id="taxdesc1" /></td>
		<td><input name="taxpercent1" type="text" class="alignright" id="taxpercent1" onblur="CalTotalOtherTax();"/></td>
		<td><input name="taxamount1" type="text" disabled="disabled" class="alignright" id="taxamount1"/></td>
	  </tr>
	  <tr id="lasttaxtr">
		<td colspan="3" class="addnew" id="addnewtax" > </td>
	  </tr>
	</table>		</td>
  </tr>
  <tr class="row2">
	<td>Profit per product (USD) </td>
	<td><input name="profitperproduct" type="text" disabled="disabled" class="alignright" id="profitperproduct" />
	  (
	  Commission + Markup amount ) 
		<input name="totalothertax" type="hidden" id="totalothertax" /></td>
  </tr>
  <tr class="row2">
	<td>Calculated Price (USD) </td>
	<td><input name="calcprice" type="text" disabled="disabled" class="alignright" id="calcprice" />
	  (Principal Price + Tax + Markup)</td>
  </tr>
  <tr class="row2">
	<td width="160">Common Price (USD) </td>
	<td><input name="commonprice" type="text" class="alignright" id="commonprice" /></td>
  </tr>
  <tr class="row2">
	<td width="160" class="text">Principal</td>
	<td class="text"><select name="principal" size="1" id="principal" onchange="addprincipal();">
	  <option>Owen Oil Tools</option>
	  <option>Oil Field Bhd.</option>
	  <option>Oil Service Tools</option>
	  <option>Green Bhd.</option>
	  <option class="blueadd" value="1">--Add New--</option>
	  <option>--Please Choose--</option>
	</select>	</td>
  </tr>
  <tr class="row2"  id="newprincipal" style="display:none">
	<td width="160" class="bgboxtitle">New Principal</td>
	<td class="bgboxtitle"><input name="textfield10" type="text" size="50" /></td>
  </tr>
  <tr class="row2">
	<td width="160" class="text">Additional Info</td>
	<td class="text"><textarea name="textfield7" cols="50"></textarea></td>
  </tr>
</table>
<br/>		
		<table cellpadding="3" cellspacing="2" align="center">
		  <tr>
			<td colspan="2" align="left" class="red">Competitor</td>
		  </tr>
		  <tr>
			<td class="bgcomptitle">Company Name</td>
			<td width="150" align="center" class="bgcomptitle">Equivalent Product </td>
		  </tr>
		  <tr>
			<td class="text">
					<select id="SEL1" name="SEL1" onchange="AddNewItem();">
					<option value="2">Oil Field Bhd.</option>
					<option>Owen Oil Tools</option>
					<option>Oil Service Tools</option>
					<option>Green Bhd.</option>
					<option class="blueadd">--Add New--</option>
					<option selected="selected">--Please Choose--</option>
				  </select>			</td>
			<td align="right" class="text">
				<input name="box" type="text" class="text" size="28" style="display:block" />
			   <select name="product" style="display:none" onchange="productlist()">
				<option>Lower Anchor Assembly w/ 90 deg wicker </option>
				  <option>Standard Stinger Assembly w/ 90 deg wicker both ends. </option>
				  <option>Top stinger section w/ latch collet 86 deg wicker @ top 90 deg at lower end.</option>
				  <option>Liner Top Completion Assembly w/ 86 deg wicker stinger </option>
				  <option>Liner deployment Assembly (LIH Price not normally left in hole) </option>
				  <option>Seal Stacks (replacement or damaged normally included) </option>
				  <option>Short Assembly, 3 1/2&quot; Patch Chrome </option>
				  <option>10 ft Section F/2.775 OD x 2.33 ID Patch,13 Chrome </option>
				  <option>5 ft Section F/2.775 OD x 2.33 ID Patch, 13 Chrome </option>
				  <option selected="selected" value="1">-Please Choose-</option>
			  </select>			 </td>
		  </tr>
		  <tr id="bgaddproduct" style="display:none">
			<td>&nbsp;</td>
			<td align="right" class="text" >
				<select name="product2" id="product2"style="display:none">
				<option>Lower Anchor Assembly w/ 90 deg wicker </option>
				  <option>Standard Stinger Assembly w/ 90 deg wicker both ends. </option>
				  <option>Top stinger section w/ latch collet 86 deg wicker @ top 90 deg at lower end.</option>
				  <option>Liner Top Completion Assembly w/ 86 deg wicker stinger </option>
				  <option>Liner deployment Assembly (LIH Price not normally left in hole) </option>
				  <option>Seal Stacks (replacement or damaged normally included) </option>
				  <option>Short Assembly, 3 1/2&quot; Patch Chrome </option>
				  <option>10 ft Section F/2.775 OD x 2.33 ID Patch,13 Chrome </option>
				  <option>5 ft Section F/2.775 OD x 2.33 ID Patch, 13 Chrome </option>
				  <option selected="selected" value="1">-Please Choose-</option>
			  </select>	
			</td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td align="right" class="addnew" id="addproduct" style="display:none; cursor:pointer" onclick="addnewpro()">Add Product!</td>
		  </tr>
		</table>
		<br/>
		<table width="600" align="center">
		  <tr>
			<td align="center"><input name="submit" type="submit" value="submit"/>
			  &nbsp;
			  <input name="submit2" type="reset" value="Reset"/></td>
		  </tr>
		</table>
		 
</form>

please help me to fix this error.. anyone ?

#2 austen

    P2L Jedi

  • Members
  • PipPipPip
  • 910 posts
  • Location:Montana, US
  • Interests:Web design, snowboarding (lots of it), Computer science related.

Posted 06 December 2008 - 09:56 AM

Firstly i would say download Firebug Firefox Addon if you haven't already... and take a look at the console on your page, see what javascript errors that produces, and either repost those here too or try to fix it, at this point i'm not sure what the actual problem is, and i don't have time to test it for myself.

Hope this helps

-austen

#3 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 13 December 2008 - 02:04 AM

Unless I am missing something, it appears you have it hard coded into the page so this would seem to be a HTML/CSS issue?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users