Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: If text string is present, do [whatever]...?

  1. #11
    Join Date
    Feb 2006
    Location
    Harpenden, Hertfordshire, England
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yeh true. The reason I have gone about it with javascript thus far is because it's all I know, I appreciate your offer to help though.

    Thing is, I am not making the whole website myself, just some of my own frames with frames from another website. This is to make browsing it easier for me, so I kind started a mini-project for myself whilst I learn more basics.

    So in basic terms:

    I want my search box (in one frame) to open the search (in the other frame). The frame where the search is opened is the website I am browsing, and do not 'own'.

    Basically, I am adding the search terms to the search function on the website that already exists via a URL. If the terms return no success in the search of the website, text will appear on the website saying something along the lines of 'Nothing matches the search' - as you might expect. This is the whole 'string' thing I was after. If this occurs, I want my search criteria to search a different URL (hence the search1 and search2 stuff previously) because the first search has been unsuccessful.

    Not sure how clearly I explained that... Be honest if it makes no sense whatsoever :P

    Much appreciate the help from you both

  2. #12
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Oh, so you really do need to parse the page it gets. Interesting.

    You could do this serverside with PHP, but it wouldn't be so much easier than JS.

    PHP Code:
    <?php
    ob_start
    ();
    include(
    'http://....myurl.com/dir/?info=stuff');
    $return ob_get_contents();
    ob_end_clean();
    if (
    strpos($return,'My_Word_or_Phrase')!==FALSE) {
    die(
    $return);
    }
    header('Location: http://my.com/error/page.htm');
    Since it nicely highlights the code, all you need to do is replace the parts in red.

    To make a really smooth system, that may need some tweaking. Rather than outputting the text, it might be a better idea to redirect to that page, as outputting it directly will cause local paths to act strangely.
    Also, getting the URL in the first place may be challenging. You can use the variables sent from the form to set the search, such as $_GET['fieldname'], $_POST['fieldname'] based on the method="" attribute of the form.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #13
    Join Date
    Feb 2006
    Location
    Harpenden, Hertfordshire, England
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Errrrrrm... lol i'll take your word for it :P

    Sorry, how would I go about implementing this to achieve what I was after with JS?

Bookmarks

Posting Permissions

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