52 users online (1 members and 51 guests)  

Thread: Java Help


  Results 1 to 2 of 2

Related

  1. Need Java Help Please    Forum: Javascript Forum
    Replies: 0
  2. help with java    Forum: Javascript Forum
    Replies: 0
  3. .NET or java??    Forum: Web Hosting Forum
    Replies: 1
  4. java vs flash    Forum: Website Scripts Forum
    Replies: 4
  1. #1
    joshharman's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2010
    Posts
    3

    Java Help

    Hi,

    Im using an ecommerce system called EKM Powershop.

    What I need help with is, I want to create an editable element, but I need the name to change depending on the path they are on the website.

    But as I edit the website in my ekm powershop the path for the editable element is

    http://youraccount.ekmpowershop4.com/ekmps/shops/firstchoice/PATH

    instead of

    http://www.firstchoicesupplements.co.uk/PATH


    I have some code working that pulls the path and splits it up, but I want to display the last path only

    so if i was on

    http://youraccount.ekmpowershop4.com/ekmps/shops/firstchoice/PATH

    it would display - PATH

    and if i was on

    http://www.firstchoicesupplements.co.uk/PATH

    it would display PATH

    the code I have at the moment is

    <SCRIPT LANGUAGE="JavaScript"><!--
    pathis=location.pathname;
    new_array=pathis.split("\\");
    subdirectory=new_array[1];
    document.write(subdirectory);
    //-->
    </SCRIPT>

    but what this does is write in the 1st path, but as it changes depending on what part of the shop i am i need to change it.

    I either need to find the length of the array and the show the last part of the array only

    or

    show the last part of the path

    if anyone nows how to do this would be awsome

    thanks

    Josh
    Last edited by HTML; 01-23-2010 at 06:35 PM.

  2. #2
    joshharman's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2010
    Posts
    3

    Re: Java Help

    Fixed it now heres the code if anybody needs to use it

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    pathArray = window.location.pathname.split( '/' );
    testvalue=pathArray.length;
    subdirectory=pathArray[testvalue - 1];
    document.write(subdirectory);
    //-->
    </SCRIPT>

    what this does is automatically pulls the last path of the URL so for example if the url was

    www.google.com/path1/path2/path3/path4

    it would take path4 out and you can use that as you wish.

    thanks

    Josh