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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function working in IE, but not Firefox

Status
Not open for further replies.

grande

Programmer
Feb 14, 2005
657
CA
Code:
function edit(entity) {
	str=document.getElementById(entity).innerHTML;
	if (str.indexOf("<INPUT") < 0) {
		document.getElementById(entity).innerHTML="<INPUT type='text' name='edit_" + entity + "' value='" + str + "'>";
	}
}

This is supposed to change text into a textbox. It works fine in IE, but not in Firefox (I haven't tested in any other browsers because I don't have any other browsers on this PC)

Any ideas?

-------------------------
Call me barely Impressive Captain.
 
1) what does firefox's javascript console say? any errors reported?

2) consider creating an input element using createElement instead of just setting the innerHTML.



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
By the way, I should say what's happening.

In Firefox, the textbox is created, but when I click on it again, it inserts the HTML to create a textbox into the textbox.

When I put an alert on indexOf("<INPUT"), it always comes back as -1 in Firefox.

-------------------------
Call me barely Impressive Captain.
 
>if (str.indexOf("<INPUT") < 0) {
[tt]if (str.[blue]toUpperCase().[/blue]indexOf("<INPUT") < 0) {[/tt]
 
I agree with tsuji: never assume the case of anything you don't have control over. Convert it to upper (or lower) case and you'll always know for certain.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top