/    Sign up×
Community /Pin to ProfileBookmark

Wierd Problem only in IE7

Hi
I know I will probably see the problem as soon as I finish posting, but I can’t find the problem in this bit of simple script right now!
This works in FF but not in IE7.

Click on the first check box, it should enable/disable the button.
The second one works.

[code=html]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<script type=”text/javascript”>
function show(a,b){
var aa=document.getElementById(a);
var bb=document.getElementById(b);
if (aa.checked==true){
bb.disabled=false;
} else {
bb.disabled=true;
}
}
</script>

</head>

<body>
<div>
<form name=”modifyhouse1″ action=”modifylisting.php” method=”post”>
<input type=”submit” id=”modifyhouse1″ value=”modify listing info” disabled=”disabled” /><br />
<input type=”checkbox” id=”modhcb1″ onclick=”show(this.id,’modifyhouse1′);” /><small>Check to be sure</small>
</form>
</div>

<div>
<form name=”modifyhouse” action=”modifylistingpics.php” method=”post”>
<input type=”submit” id=”modifyhousepics1″ value=”modify listing pics” disabled=”disabled”><br />
<input type=”checkbox” id=”modhpcb1″ onClick=”show(this.id,’modifyhousepics1′);”><small>Check to be sure</small>
</form>
</div>
</body>
</html>
[/code]

Thanks.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@KorFeb 12.2008 — Try DOM 1
<i>
</i>...
if (aa.checked){
bb.removeAttribute('disabled');
} else {
bb.setAttribute('disabled','disabled');
}
...
Copy linkTweet thisAlerts:
@gomisuteauthorFeb 12.2008 — 

Thanks, I'll try, but the second button works in IE7, though!???
---


I'll let you know if your suggestion works.

This is strange.
Copy linkTweet thisAlerts:
@gomisuteauthorFeb 12.2008 — OK.

I tried your suggestion KOR.

It still didn't work in IE7.

However, no matter what, I was not getting a script error!!!

So here is what I looked at.

If you notice my FORM's name:
[code=html]<form name="modifyhouse1" action="modifylisting.php" method="post">[/code]

and my button's ID:
[code=html]<input type="submit" id="modifyhouse1" value="modify listing info" disabled="disabled" />[/code]

They are the same!!! That shouldn't matter at all...

but I changed the FORM's name to a different name and it works in IE7, as well.

So there is a BUG for you in IE7!!!!!!!

Hope this helps someone.

Thanks for your help.

(Now I gotta figure out how to mark this resolved...never did figure that out).
Copy linkTweet thisAlerts:
@KorFeb 12.2008 — You must avoid giving to a [B]name[/B] of an element and to an [B]id[/B] of [I]another[/I] element the [I]same[/I] value, your case "modifyhouse1".

Silly IE takes a [B]name[/B] of an element as [B]id[/B], if the id is missing. Or the id must be unique on document/session, thus IE is confused, as it sees 2 elements with the same id... Remember that.

On the other hand, you should rather give an [B]id[/B] to the form, and [B]names[/B] to its elements.
Copy linkTweet thisAlerts:
@gomisuteauthorFeb 12.2008 — 
Silly IE takes a [B]name[/B] of an element as [B]id[/B], if the id is missing. Or the id must be unique on document/session, thus IE is confused, as it sees 2 elements with the same id... Remember that.[/QUOTE]

Silly, IE indeed...

I'll certainly remember that from now on.


On the other hand, you should rather give an [B]id[/B] to the form, and [B]names[/B] to its elements.[/QUOTE]


Yes, this is a better way...after all names were around before IDs came along.

Thank you.
×

Success!

Help @gomisute spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...