/    Sign up×
Community /Pin to ProfileBookmark

Onclick event works in Mozilla but fires unwanted events in IE

Hi.
I think I’ve searched the forums but can’t find anything quite like this. Help will be much appreciated.
My problem can be seen online at
[URL=”http://www.orientalrugsonline.co.uk/search.jsp”]http://www.orientalrugsonline.co.uk/search.jsp[/URL]

The search for size ranges works fine in Mozilla but in IE, it always returns the result for “Large” whichever range you click.

The ranges are 4 <SPAN> elements containing images with onclick events in the jsp:


******************************

<span id = ‘lgeSpan’ onmouseover=”this.style.cursor=’pointer'”
onclick=”clearCriteria(”);
submitSizeValues(”,’250′,”,’170′);
“>
<img width=”100″ height=”130″ src=”pics/LargeSearch.jpg” border=”1″>
</img
</span>

<span id = ‘medSpan’ onmouseover=”this.style.cursor=’pointer'”
onclick=”clearCriteria(”);
submitSizeValues(‘255′,’145′,”,’100’);
“>
<img width=”80″ height=”100″ src=”pics/MediumSearch.jpg” border=”1″>
</img
</span>

<span id = ‘smallSpan’ onmouseover=”this.style.cursor=’pointer'”
onclick=”clearCriteria(”);
submitSizeValues(‘150’,”,”,”);
“>
<img width=”55″ height=”70″ src=”pics/SmallSearch.jpg” border=”1″>
</img
</span>

<span id = ‘runSpan’ onmouseover= “this.style.cursor=’pointer'”
onclick=”clearCriteria(”);
submitSizeValues(”,’200′,’110′,’45’);
“>

<img width=”40″ height=”130″ src=”pics/RunnerSearch.jpg” border=”1″>
</img

</span>

Javascript function is


*******************

function submitSizeValues(maxL, minL, maxW, minW)
{
document.searchForm.MaxLen.value = maxL;
document.searchForm.MinLen.value = minL;
document.searchForm.MaxWid.value = maxW;
document.searchForm.MinWid.value = minW;
document.searchForm.setSearch.value = ‘Y’;
document.searchForm.submit();
}

Debug analysis – Mozilla


************************

When the code runs in Mozilla (using my local server), I get this debug output on clicking “SMALL” for instance, showing the correct xpath (rugs <= 150 cm long) which finds the correct results from my XML inventory
JUSTIN – searchRes – point 1
SSourceXML: XML/Inventory.xml
SearchHelper bean XPATHL: [L <= 150]
JUSTIN – point 10

In IE, however, for a single click on “SMALL”, I get


*****************************************************

JUSTIN – searchRes – point 1
SSourceXML: XML/Inventory.xml
SearchHelper bean XPATHL: [L <= 150]
JUSTIN – point 10
strSource: javax.xml.transform.stream.StreamSource@eaf40c
JUSTIN – searchRes – point 1
SSourceXML: XML/Inventory.xml
SearchHelper bean XPATHL: [L <= 255 and L >= 145 and W >= 100]
JUSTIN – point 10
strSource: javax.xml.transform.stream.StreamSource@5eb489
JUSTIN – searchRes – point 1
SSourceXML: XML/Inventory.xml
SearchHelper bean XPATHL: [L >= 250 and W >= 170]
JUSTIN – point 10
strSource: javax.xml.transform.stream.StreamSource@a522a6

In other words, we have fired the onclick from the current <SPAN> but also the one before (medium) and the one before that so that we always end up with the result from the first (Large). How do I stop these additional onclick events?

Can anyone help, please?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@voidvectorFeb 06.2009 — Try validating your HTML. "</img" is not a valid tag.
Copy linkTweet thisAlerts:
@rugmanauthorFeb 06.2009 — Thank you so much, voidvector. I might have know the answer I've been frantically searching for for 6 hours would be embarassingly simple.:rolleyes:


I'm only an occasional programmer and this sort of thing seems to happen to me a lot (I used to program in visual basic and I really miss the line-by-line debugging you can do). I definitely need some validation tools. What products do you recommend for validation of html, javascript, xslt and css? (we also have some server side java classes but I suppose the compilation is also the validation for these). Thanks again.
Copy linkTweet thisAlerts:
@voidvectorFeb 06.2009 — For HTML, use W3C HTML validation service. Try validate HTML as much as possible, because most of the errors on web pages can be corrected with a validated HTML page. I would only give up if I desperately want a feature that would cause it to fail validation. There should be a downloadable version somewhere if you don't wish to send your HTML code to w3c server.

For CSS, use W3C CSS validation. Try validate CSS if you can. However, people use CSS hack very often, which would cause validation failure.

For JavaScript, make sure you check the error console that no error come up. This is the most basic validation. If you want hardcore "JavaScript validation", you can use JSLint. I put that in quotes because it is not really syntax validation, but enforcing a strict programming style. JSLint is pretty strict for a casual programmer, so you might want to read its documentation page before deciding whether it is for you.

For XML (such as XSLT), just open the XML file with a browser, and make sure the browser doesn't report any syntax error.
Copy linkTweet thisAlerts:
@rugmanauthorFeb 06.2009 — Thanks Fang. There's an awful lot of errors! I'm frankly surprised the site works at all! What I need now is an automatic error correction facility!
Copy linkTweet thisAlerts:
@rugmanauthorFeb 06.2009 — And more thanks to you too voidvector.
×

Success!

Help @rugman 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.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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