script needed.

Discussion in 'HTML & Website Design' started by continuum, Oct 23, 2007.

  1. #1
    Does anyone know of a script that sends the name of the page that the person was on. i.e. similar to a directory script that fill in the category when you click on the "add URL" button
     
    continuum, Oct 23, 2007 IP
  2. webdesigner

    webdesigner Well-Known Member

    Messages:
    489
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    110
    #2
    One way could be with a simple PHP

    At the top of the page you could have something like:

    
    <?
    $page = "Page1";
    ?>
    
    Code (markup):
    and then later on in the page, you could recall that:

    
    <?
    if ($page == "Page1") echo ' WHATEVER YOU WANT '
    else if ($page == "Page2") echo ' WHATEVER YOU WANT '
    else if ($page == "Page3") echo ' WHATEVER YOU WANT '
    else if ($page == "Page4") echo ' WHATEVER YOU WANT '
    ?>
    
    Code (markup):
    That the sort of thing you thinking of? It can be adapted in many ways, just depends on your needs.
     
    webdesigner, Oct 24, 2007 IP
  3. continuum

    continuum Well-Known Member

    Messages:
    571
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    110
    #3
    For example, I have an accommodation website that has 15000 pages (all different places)I want clients to be able to go to one of these (for example - Barmedman page which is called BarmedmanNSW.htm) and click on a button to advertise their site.

    When it goes to the next page (a registration form) I want the name of the town (Barmedman - without the NSW) to be prefilled in the form.

    Hope this explains it better.
     
    continuum, Oct 24, 2007 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It would depend on how many different "end bits" you have - if they are all NSW.htm or they would all be 7 characters as this one is then it is easy. If they are all different and different lengths etc then it depends if they are static or will be ever changing (as a whole not individual locations)

    Assuming they are all NSW.htm then:
    
    If Not Page.IsPostBack Then
       TextBoxID.Text = Request.UrlReferrer.AbsolutePath.Replace("NSW.htm", "")
    End If
    
    Code (.Net):
     
    AstarothSolutions, Oct 24, 2007 IP
  5. continuum

    continuum Well-Known Member

    Messages:
    571
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Thanks for that. Fortunately, there are only 7 endbits.

    I will try this.

    Thanks for your help.
     
    continuum, Oct 25, 2007 IP