Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Javascript Error?

Hello,

See attached html. Notice on line 361 the value assigned to sct contains the html code &#39.

Notice on lines 105 - 106 in the JavaScript chk_vals function. The alert fails to show in this case (& ONLY this case). The page reverts to the "outer" page (this is all generated from php).

Obviously, it's connected to the &#39.

What's wrong?

Thanks
manage-subcategory.htm
Avatar of WebDevEM
WebDevEM
Flag of United States of America image

Hi,

The first thing I noticed is that you're missing a semicolon after line 105.  I've been told by some that they're optional in some cases, but I always use them to end each and every line.  (I figure if it's there and doesn't need to be, it won't cause an error anyway)
&#39  should be '


Cd&
Avatar of Dave Baldwin
Actually, you have two encoding problems.  A single quote can be encoded as ' in your HTML... but that is not legal in URLs because '&' and '#' are reserved characters.  In URLs the single quote should be 'percent encoded' as %27.  http://en.wikipedia.org/wiki/Percent-encoding
Oh you are right, I only saw the first one.

Cd&
Avatar of Richard Korts

ASKER

To all,

Adding the ; to &#39 did not change anything. Still the same,

I understand about the query string, but that method is not used here. The value with the "&#39l" is passed as a form variable (POST method).

But the FIRST problem is, the alert in the JavaScript function does not work.

Using FireFox error console shows NO JavaScript errors.

Revised html attached.
manage-subcategory.htm
You have '&#39', '&#34' and '&#47' embedded in the query strings of quite a few links.  And since you're not giving us the 'real' link, none of the CSS and 'js' files are loading.
We are Experts Dave! We are supposed to be able to overcome a lack of co-operation. :^(

Cd&
We do! We throw these things against the wall and see what happens.  How's your beer, Cd&?
I see the links you are referring to; I'd forgotten that it does that too. I don;t think that's germane to this issue, but maybe.

The reason I can't give you a real link is that this is a php program that is called from a menu, accesses a database, etc. I do not want to put the "real" database connection string on EE for the obvious reasons.

If you like I will assign both of you (Dave Baldwin & Cobol Dinosaur) a temporary login to the site if I can email it directly to you; obviously, I don't want to post that on EE either.

Attached are the css & those js files.

I am not trying to be uncooperative. Obviously, I need this issue solved.
style.css
layout.css
reset.css
typography.css
cufon-yui.js
custom.js
ddaccordion.js
navigation.js
helveticatitle-400-helveticatitl.js
homevetica-italic-900.font.js
You can look on my profile and get my web site and use the form there to send me an email.  I won't look at the files by themselves because it is often the interaction on the site that causes problems.
To Dave Baldwin,

Email sent.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You mean I put the \ in front of the '?

Maybe I can use double quotes in defining sct; but I don't think so.

Richard
No, I meant what I said and showed above.  Don't use ' in the javascript unless you want it to be interpreted as a single quote.  If you used double quotes inside a string that is already double quoted, you would have to use \" to escape them also.

You have to use different kinds of encoding in different places.  That's just the way it is.
Very good persistence. Great work.