document.getElementById aint working in Firefox/Safari

Discussion in 'JavaScript' started by protocol96, Nov 5, 2007.

  1. #1
    
    <script language="javascript" type="text/javascript">
    v_0=0;
    function adjustTotal(src, dest, pr)
    {   
    
        var price = parseFloat(pr);
        alert("t  " + src);
    //    document.getElementById('<%=TextBox1.ClientID%>').value = "some value";
    	 obj1.innerText =document.getElementById(src).value;
    	//getElementsByName(src);
    	alert("obj1  " + obj1.innerText);	
    	//var obj2 = document.getElementsByName(dest);	
    	var obj2=document.getElementById('<%=lblprice.ClientID%>').value;
    //	document.getElementById(). 
    	alert("obj2  " + obj2.innerText);
    //	originObj = document.getElementById('origin');
    //    destinObj = document.getElementById('destin');
    
    //    document.getElementById(src).value = obj1.value;
    //    document.getElementById(dest).value = obj2.value;
        
    	if (obj1 != null && obj2 != null)//&& !isNaN(price))
    	{
    		//make sure user has entered a number, else it is 0. 
    		var v = 0;
    		if (obj1.value != "" )//&& !isNaN(parseInt(obj1.value))) 
    			v = parseInt(obj1.value)*price;		    	
    		var t = parseFloat(obj2.innerText);
    		v_0 = v_0 * price;
    		var total = t+v-v_0; 
    			
            obj2.innerText;
            obj2.innerText = total.toFixed(2);
            alert(obj2.innerText);
            }
    	}
    //}
    /* src - the id with the textbox to record the initial value of */
    function adjustInit(src)
    {
    	var obj1 = document.getElementById(src);	
    
    	if (obj1 != null )
    	{
    		if (obj1.value != "" )//&& !isNaN(parseInt(obj1.value)))
    			v_0 = parseInt(obj1.value);
    		else
    			v_0 = 0; 
    	}
    }
    </script>
    
    
    PHP:

    document.getElementById aint working in Firefox/Safari. Can somebody please help.

    Additional Updates:
    Its working in IE though
     
    protocol96, Nov 5, 2007 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    MMJ, Nov 5, 2007 IP
  3. protocol96

    protocol96 Peon

    Messages:
    413
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    passing thru asp.net
     
    protocol96, Nov 5, 2007 IP
  4. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #4
    The usual cause of this problem is when the parameter passed is actually a name attribute instead of an id. Since you haven't shown the element, it's not possible to tell.
     
    Logic Ali, Nov 5, 2007 IP