Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Location
    Romney Marsh, Kent, England
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    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
    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/

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Location
    Romney Marsh, Kent, England
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    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
    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.
    Last edited by nikkiH; 08-15-2005 at 08:16 PM.

    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/

  • #5
    New to the CF scene
    Join Date
    Aug 2005
    Location
    Romney Marsh, Kent, England
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    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
    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>');
    Last edited by nikkiH; 08-15-2005 at 09:41 PM.

    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/

  • #7
    New to the CF scene
    Join Date
    Aug 2005
    Location
    Romney Marsh, Kent, England
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #8
    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
    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/

  • #9
    New to the CF scene
    Join Date
    Aug 2005
    Location
    Romney Marsh, Kent, England
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #10
    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
    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/

  • #11
    New to the CF scene
    Join Date
    Aug 2005
    Location
    Romney Marsh, Kent, England
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •