Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-13-2005, 03:22 AM   PM User | #1
JL107
New to the CF scene

 
Join Date: Aug 2005
Location: Romney Marsh, Kent, England
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
JL107 is an unknown quantity at this point
Help with js menu pointing to php pages

Hi,

I'm not sure whether this fits here or whether it's really a php question but...

The following lines are from a js menu that I want to use on my site. However, both links return the same page although the second one should return the page for an individual category. Can anyone tell me whether it is possible to link to php pages in this manner? If so, how is it done?

document.write('</td></form><form action="categories.php"><td>');
document.write('<input type="submit" value=" Buy Online " onmouseover="this.className=\'buttonon\'" onmouseout="this.className=\'button\'" class="button"><br>');

document.write('</td></form><form action="categories.php?cat=1"><td>');
document.write('<input type="submit" value=" Artists " onmouseover="this.className=\'buttonon\'" onmouseout="this.className=\'button\'" class="button"><br>');

Many thanks
JL107 is offline   Reply With Quote
Old 08-15-2005, 03:08 PM   PM User | #2
nikkiH
Senior Coder

 
nikkiH's Avatar
 
Join Date: Jun 2005
Location: Near Chicago, IL, USA
Posts: 1,973
Thanks: 1
Thanked 32 Times in 31 Posts
nikkiH is on a distinguished road
That should work. I've done it before without any problems.
Perhaps it's your PHP on the handling page that is not correct.
__________________

If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit
http://www.kaelisspace.com/
nikkiH is offline   Reply With Quote
Old 08-15-2005, 03:30 PM   PM User | #3
JL107
New to the CF scene

 
Join Date: Aug 2005
Location: Romney Marsh, Kent, England
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
JL107 is an unknown quantity at this point
Many thanks for the reply.

I think that the PHP is OK. The javascript is in an external file but I have also tried inserting it directly into the page with the same result. If I view the source the correct link shows. I've also tried using the full path to the page but without success. All the other javascripts on the page work flawlessly.
JL107 is offline   Reply With Quote
Old 08-15-2005, 08:12 PM   PM User | #4
nikkiH
Senior Coder

 
nikkiH's Avatar
 
Join Date: Jun 2005
Location: Near Chicago, IL, USA
Posts: 1,973
Thanks: 1
Thanked 32 Times in 31 Posts
nikkiH is on a distinguished road
What happens if you type in the page directly with that param?
i.e.
categories.php?cat=1
Does it show the right stuff?
Got URL?
Might be an issue with having multiple forms with no names or some such. I assume you only copied part of the page, since your forms have no (required) </form> tag.
__________________

If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit
http://www.kaelisspace.com/

Last edited by nikkiH; 08-15-2005 at 08:16 PM..
nikkiH is offline   Reply With Quote
Old 08-15-2005, 08:38 PM   PM User | #5
JL107
New to the CF scene

 
Join Date: Aug 2005
Location: Romney Marsh, Kent, England
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
JL107 is an unknown quantity at this point
Thanks for the suggestion.

I have just tried adding the link categories.php?cat=1 as a hyperlink to some text on the page and it works perfectly.

I will now demonstrate my total ignorance of javascript.

The javascript is in a file menu.js which consists entirely of lines similar to the ones I gave earlier. At the position that the menu appears is simply the line <script language="JavaScript" src="menu.js"></script>.

All the buttons/links work perfectly except for ignoring the ?cat=*** at the end of some of the links.

An odd thing that I have just noticed is that the address bar in IE6 shows ? at the end of all page addresses (including html pages).

As a (hopefully) temporary work around I have cloned the affected pages and saved them as .htm and then changed the links in menu.js to link to them.
JL107 is offline   Reply With Quote
Old 08-15-2005, 09:36 PM   PM User | #6
nikkiH
Senior Coder

 
nikkiH's Avatar
 
Join Date: Jun 2005
Location: Near Chicago, IL, USA
Posts: 1,973
Thanks: 1
Thanked 32 Times in 31 Posts
nikkiH is on a distinguished road
An odd thing that I have just noticed is that the address bar in IE6 shows ? at the end of all page addresses

And what does it show for the ?cat=1 pages?

It is showing the ? at the end because what is really happening is a form submit, which is defaulting to get since method isn't specified.
That's why I mentioned the lack of </form> and such (which I see now is in fact there; I missed it).

Try this just for giggles. Change the lines to include the category as a hidden var and take it out of the action.

document.write('</td></form><form action="categories.php"><td>');
document.write('<input type="hidden" name="cat" value="1">');
document.write('<input type="submit" value=" Artists " onmouseover="this.className=\'buttonon\'" onmouseout="this.className=\'button\'" class="button"><br>');
__________________

If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit
http://www.kaelisspace.com/

Last edited by nikkiH; 08-15-2005 at 09:41 PM..
nikkiH is offline   Reply With Quote
Old 08-15-2005, 10:05 PM   PM User | #7
JL107
New to the CF scene

 
Join Date: Aug 2005
Location: Romney Marsh, Kent, England
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
JL107 is an unknown quantity at this point

I take my hat off to you (or at least I would if I were wearing one). The fuller code works.

The ?cat=1 page shows just that, (following the .php of course).

I think I must be getting senile, on looking again at menu.js I find that there are other lines of code at the beginning and end of the script.

I notice that you have edited your post, but if you still want to see the code it is on a site that I am working on for a friend. I have uploaded my efforts so far to: http://www.windsorart.co.uk/ and the menu.js file is in the home directory.

I think I will replace the whole menu.js script with the extended version.

Once again, many thanks
JL107 is offline   Reply With Quote
Old 08-16-2005, 02:37 PM   PM User | #8
nikkiH
Senior Coder

 
nikkiH's Avatar
 
Join Date: Jun 2005
Location: Near Chicago, IL, USA
Posts: 1,973
Thanks: 1
Thanked 32 Times in 31 Posts
nikkiH is on a distinguished road
You're welcome!
I wanted to see the code because although making it a form field may fix the problem, I don't see why putting it in the action didn't work in the first place. Is till don't.
But glad you got it working.

I did notice that the menu is creating invalid html (no element may be a child of a TR except a TD, yet the forms are children of the TR) but that shouldn't have hurt anything. To make it valid, just move the <form> and </form> inside the TD instead of outside them.

Also, the categories pages are off in Firefox. The footer is left instead of centered and messes up. Don't know if you knew that.
__________________

If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit
http://www.kaelisspace.com/
nikkiH is offline   Reply With Quote
Old 08-16-2005, 07:31 PM   PM User | #9
JL107
New to the CF scene

 
Join Date: Aug 2005
Location: Romney Marsh, Kent, England
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
JL107 is an unknown quantity at this point
Just when I thought it was all going so well!!!

I think that I have now sorted the Firefox footer problem. I decided to make ithe footer 100% width.

I have also changed the menu.js and moved all the Form tags inside of the cell tags but that has caused its own problem with the appearance of what seems to be an additional row beneath the menu. This only appears in IE and not in Firefox.

Also, in Firefox, my Clearpixel.gif (spacer) images show up. Is this normal?
JL107 is offline   Reply With Quote
Old 08-16-2005, 11:00 PM   PM User | #10
nikkiH
Senior Coder

 
nikkiH's Avatar
 
Join Date: Jun 2005
Location: Near Chicago, IL, USA
Posts: 1,973
Thanks: 1
Thanked 32 Times in 31 Posts
nikkiH is on a distinguished road
Forms have margins and paddings.
Set them to 0 in the CSS.
IE "fixed" it for you when it was invalid.

Might fix that spacer image thing, too.
I didn't check, but you DO have a doctype with a URL in there, right? Not doing so sets off quirks mode, the biggest thing most likely to make pages behave differently cross-browser.
__________________

If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit
http://www.kaelisspace.com/
nikkiH is offline   Reply With Quote
Old 08-17-2005, 12:20 AM   PM User | #11
JL107
New to the CF scene

 
Join Date: Aug 2005
Location: Romney Marsh, Kent, England
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
JL107 is an unknown quantity at this point
I reverted to the original nesting of cells and forms which cured the IE problem of the extra row (although I think that it was actually a double height row). In doing so I found an extra <td> tag which may have been what was throwing up the invalid html.

All of my pages have doctype attributes but none of the php scripts that are called as includes nor the .js files have them.

Setting the height of the spacer images to 1 has disappeared them without any obvious effect on page layout.

I think I'll quit whilst I'm ahead and start working on the content for a while.

Once again, my most grateful thanks. I owe you a beer or two!!
JL107 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:13 AM.


Advertisement
Log in to turn off these ads.