Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript doesn't work in Firefox 2

Status
Not open for further replies.

indupriya9

Programmer
Oct 29, 2002
99
NZ
Hi everyone

I have a javascript that works in IE but not in Firefox.

Here is the code

Code:
function addtoorderform(rid,prodId,proname,UnitPrice,no)
{
var nX;
var Qty;
nX=eval("document.getElementById('txtQty" + no +"')");
//alert(nX.value);
Qty=nX.value;
if(nX.disabled!=true)
{window.opener.popSetTicker(rid,prodId,proname,UnitPrice,Qty);}
	nX.disabled=true
}

What the function does is adds the values in the main form from the subform.

Any ideas on how to fix this please?

Thanks in advance
ip
 
- How does it not work?

- What does it do that it shouldn't?

- What should it do that it doesn't?

- Do you see any errors?

- What are you passing into the function?

- What does your HTML code look like?

Help us to help you ad give us something to go on.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi

There is no evident error in the code fragment you posted. Just a matter of style and readability : avoid the use of [tt]eval()[/tt].
Code:
nX=document.getElementById('txtQty' + no);

Feherke.
 
I'm betting the problem lies in this function
Code:
popSetTicker(rid,prodId,proname,UnitPrice,Qty);}

[monkey][snake] <.
 
Hi Guys

Thanks for your replies.

Feherke, I have removed the eval function and now the nx.value is returned as 'undefined' in IE and in Firefox. But removing the eval resulted in at least returning the values to the main form in firefox which was not the case earlier.

Dan, to answer your questions,

- How does it not work?
In firefox when I use the eval function, the values are not returned to the main form. When we click on the button nothing happens.

- What does it do that it shouldn't?
It doesnot do anything

- What should it do that it doesn't?
It does not return the values to the main form.

- Do you see any errors?
I donot see any errors in firefox


- What are you passing into the function?
I am passing values through the popset ticker record id, product id, name, qty and price

- What does your HTML code look like?
I am calling the function from an xsl document as shown below

Code:
				<xsl:attribute name="onclick">addtoorderform('<xsl:value-of select="rId" />','<xsl:value-of select="Code_" />','<xsl:value-of select="Product_Name" />','<xsl:value-of select="Price" />','<xsl:number value="position()" format="1" />')</xsl:attribute>

I have the function also in the xsl document.

Please let me know how to fix the undefined?

Thanks
ip
 
Hi Guys

Its me again. TT has answered my queries again. I have found the answer in MonkSnakes' resposes to one of the existing threads as shown below.

monksnake (Programmer) 15 May 07 12:41
To remove any warnings in FF, give your elements IDs instead of names and reference them with

Code:
document.getElementById("id")

Of course, it took me a while to figure out as I was using XSL document. Here goes a star for you Monksnake.

Another star for Feherke because you pointed out to me that you need not use the eval function.

Thanks a lot.
ip

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top