Display results of a submit form (getting url) in same window??

This is a discussion on "Display results of a submit form (getting url) in same window??" within the JavaScript Forum section. This forum, and the thread "Display results of a submit form (getting url) in same window?? are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Nov 7th, 2007, 17:39
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Display results of a submit form (getting url) in same window??

Hey hey!
Code: Select all
blizma.co.uk
There is my website which i need help with. (please dont comment on the poor graphics =D)

Riiiight,
I would like that when the user hits the submit button, that the results are displayed in a box in the same window, underneath the search form =D

I have no idea if this is possible.. but an example script or such would be awsome =D
Im guessing that the submit button would be edited where 'target=_blank' is?

Extreme thankyouness in advanced =D
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Nov 7th, 2007, 18:23
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,794
Thanks: 0
Thanked 17 Times in 17 Posts
Re: Display results of a submit form (getting url) in same window??

I dont know anything about JS or Ajax but i think this may have to be achieved using Ajax.

Could this: http://www.captain.at/howto-ajax-form-post-request.php be what you are looking for?
__________________
Marc
Staff Manager - Webforumz.com


Want to be a moderator? PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Nov 7th, 2007, 18:31
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

thanks for the reply!

Well... simular...just not so complicated...ajax is where i got the idea from =D and iv seen it done in js.

I have researched a little, and as i said above, i THINK it the post=_blank (or w/e) i have to edit... like post=frame ... bla bla pxls.

Thank you again for the reply though.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Nov 8th, 2007, 06:18
Up'n'Coming Member
Join Date: Jun 2007
Location: Germany
Age: 23
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

It is very good to help you with your problem with a completely crypted source code... ^_-
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Nov 8th, 2007, 21:14
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

ok i made a link with the decrypted code
Code: Select all
http://www.blizma.co.uk/for/web/forumz/index.htm
sorry =D

Last edited by jahphill; Nov 8th, 2007 at 21:19.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Nov 9th, 2007, 07:25
Up'n'Coming Member
Join Date: Jun 2007
Location: Germany
Age: 23
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

Ok, you should eliminate the "target='_blank'" that will always open a new page. Replace it with OnSubmit=\"return getresults();\"

At the place where the results should be displayed, add a div with "<div id='resultdiv'></div>"

Then, take this AJAX Javascript from me (I have prepared it for a little ajax tutorial, so there are many comments) and add it to your page in the head.
Code: Select all
function getresults()
{
    var http_request = false; // reset the request

    if (window.XMLHttpRequest) { // Simply create httprequest for any good browser... *g*
        http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // ... do the same for Internet Explorer (crazy as always)..
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    // Something went wrong?! Show error message and cancel.
    if (!http_request) {
        alert("Critical error!\nCannot create a httprequest. Cancelling.");
        return false;
    }

    http_request.onreadystatechange = refresh_page; // This funtion will be activated each time the state of the request changes. See below.
    http_request.open('POST', 'monstersearchmachine.php', true); // Opens the request to the specified file, parameter method POST is used.
    http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // tell the server what is coming through the request (needed for POST)
    http_request.send('searchType=' + document.tehmonkey.searchType.value + '&searchTerm=' + document.tehmonkey.searchTerm.value); // Send the request using the specified parameters
    
    return false;
}

function refresh_page()
{
    // check the state of the request ( 0 = not initialised; 1 = loading; 2 = loaded; 3 = interactive; 4 = complete). It is just "4 or not 4, that is the question!" ^^
    if (http_request.readyState == 4) {
        // completed!         
        // Now check the responsestate (normal HTTP states, 404 is not found for example.) Just check if everything is okay (200), or not.
        if (http_request.status == 200) {
            // perfect. handle results
            document.getElementById('resultdiv').innerHTML = http_request.responseText; // get the response and write it into the div
        } else {
            // there was an error.
            document.getElementById('resultdiv').innerHTML = "There was an error, try again later"; // write it into the div
        }
    }else{
        // not yet ready, show loading
        document.getElementById('resultdiv').innerHTML = "Loading, please wait..."; ; // Show loading
    }
}
So, if you submit the form, the script will be loaded, taking all information from the script, and sends it to the monstersearchmachine.php, gets the result of the php and writes it into the DIV.
When there is no Javascript activated, it will continue loading a second page!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Nov 10th, 2007, 16:17
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

Hey hey!!

Thanks so much for that reply =D

I have updated it, however it does not work for me, i have probably done a foolish mistake =[ but im not sure what =D

Could you have a peak in my source? =D
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Nov 10th, 2007, 18:32
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

For starters this line

document.tehmonkey.search.focus();

is incorrect, there is no form element named 'search', from looking at your source, it should be

document.tehmonkey.searchTerm.focus();

also

OnSubmit=\"return getresults();\" should just be

OnSubmit="return getresults();"

Fix these first as I think this is having a flow-on effect for the rest of the script
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Nov 10th, 2007, 18:51
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

Okie, updated that.. still no result =D =[ infact the search button does not work at all now =[
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Nov 10th, 2007, 19:05
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

Move

var http_request = false; // reset the request

to the top of the script before

function getresults()
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Nov 10th, 2007, 19:43
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

Hmm..

Yet another error occured, it says

'There was an error, try again later'


I have just read through some information about copyright and content etc. finding that i would be braking the law displaying other websites within my website =S (this does not apply for google, but for other websites which the form searched)

=[ which sucks...

The reason i created it was for a legal alternative to programs loaded with spyware, viruses, and rubish like that.
...well it is not legal, but the website was made to give indirect links, using google.

Thank you for all your help, but my decision is to stay on the right side of the law =D

Thanks for the ajax script, good luck with your tutorial!
Rakuli - > see ya around on your site =D
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Nov 17th, 2007, 14:21
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

hey =D
a little embarrassing but i'd like to continue this project =D

Id just like to change it a little:
That this function is only used when the target site is google, where it only displays the results.
Possible?

=D

>*huge blush*<
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Nov 28th, 2007, 23:18
Up'n'Coming Member
Join Date: Oct 2007
Location: room
Age: 18
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Display results of a submit form (getting url) in same window??

id like to rudely bump tis thread =[

link update :

Code: Select all
http://blizma.co.uk/for/web/forum/z/com/only/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit options and open results in a new window xshane JavaScript Forum 2 May 21st, 2008 10:23
Submit a form in popup to the parent window hassan1365 JavaScript Forum 2 Jan 25th, 2008 08:34
submit many forms - auto submit the same form many times divs JavaScript Forum 0 May 24th, 2007 10:10
Submit form results to file/folder cat101 PHP Forum 9 Nov 10th, 2006 12:00


All times are GMT. The time now is 05:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42