Jump to content

help needed again


Recommended Posts

Hi,

 

As some of you will know from my other posts I also sell broadband.

 

I am having a little difficulty intergrating my broadband checker into the front page of my site.

 

I have a form submission which calls the bt checker and then returns the results in the same page using ajax - lets call this page broadbandchecker.php:

 

<form action="adsl_availability.php" method="post" onsubmit="return Ajax_GetResponse(this)">

where adsl_availibility is the script

 

Now that all works fine for the broadbandchecker.php.

 

I want the form on the front page to submit the query to adsl_availability but return the result on broadband.php using the ajax..

 

anyone have any pointers? I'm pretty sure I need to change this line:

onsubmit="return Ajax_GetResponse(this)"

but I'm a bit stuck!

 

Thanks for any help

 

Ad

Link to comment
Share on other sites

yeh I do on the broadbandchecker.php page but not in the index page as I want that result displayed on the broadbandchecker.php page.. if that makes sense !! If I leave the form as is on index.php it tries to display result there which doesn't work as nowhere for it be displayed!

Link to comment
Share on other sites

Try this:

 

if ( reply ) {

document.getElementById('Results').innerHTML = reply;

document.getElementById('ResultsTitle').style.display = 'block';

} else {

 

to

 

if ( reply ) {

document.location = "http://onestopdigital.homeip.net/onestopdigital/broadbandchecker.php";

document.getElementById('Results').innerHTML = reply;

document.getElementById('ResultsTitle').style.display = 'block';

} else {

 

 

OR NOT USING AJAX:

 

post or get your telephone or postal code to broadbandchecker.php and include the script output in your page.

 

this returns the results you want, for instance, so you just need to do an include, file or fopen, or whatever yor preferred way is. (I will remove this link shortly after your response)

 

[Link removed]

Link to comment
Share on other sites

if ( reply ) {

document.location = "/broadbandchecker.php";

document.getElementById('Results').innerHTML = reply;

document.getElementById('ResultsTitle').style.display = 'block';

} else {

 

Now that is on the way.. the page is chaning to broadbandchecker.php but with no result... excellent this gives me something to work from :)

 

Re including the script .. this nearly works, but when you load broadbandchecker.php in it's own right be defualt you are given a "postcode not found" error.

 

Thanks for your help - sometimes I just need a shove in the right direction! I'll post back any more results I get!

 

Adam

Link to comment
Share on other sites

Okay, that may be because of the way you are setup, right now, it's going to your private IP space.

Also, note that for the else condition, you'd want to do something similar, so it goes to a page that says not available.

 

>>Re including the script .. this nearly works

 

you need to include the necessary variables so it will actually perform the check.

so if you are using post you will want to do something like:

 

if(trim($_POST["postcode"])){

submit with fopen or curl form here with all required variables

or use file()

echo result

}

Link to comment
Share on other sites

Not sure it's because it's my private IP space - by introducing the document location it is refreshing the page and I think losing the data so it has no result to display. If you try it in broadbandchecker.php you can see the page refresh.

 

What it has made me think though is that for the main broadbandchecker page I can use Ajax and for the index page I can include the script in a hidden div and use js to display it...

Link to comment
Share on other sites

for instance, make a new php file with the following and then browse to it:

(I would normally do this with curl or fopen, but file will work too.)

 

<?php

 

//do by postcode:

$results = file('$location');

 

print_r($results);

 

echo "

 

Results of the file array[1]

 

";

 

echo $results[1];

 

echo "

Results of the file array[2]

 

";

 

echo $results[2];

 

?>

Link to comment
Share on other sites

Not sure it's because it's my private IP space - by introducing the document location it is refreshing the page and I think losing the data so it has no result to display. If you try it in broadbandchecker.php you can see the page refresh.

 

What it has made me think though is that for the main broadbandchecker page I can use Ajax and for the index page I can include the script in a hidden div and use js to display it...

 

You do have a point, and refreshing may cause some different behaviour effects in different browsers, thus why I suggested, just grabbing the output on form post or get... you don't need ajax for that at all.

Link to comment
Share on other sites

Although I do wonder if there is a way to stop the page refreshing when using

 

document.location = "path to file";

 

as it actually does the job and displays the results but then refreshes and looses them - this would be an ideal solution :)

Link to comment
Share on other sites

you can, but as mentioned before, the behaviour is different in various browsers, so you would need to account for that too.

 

since you want the results on a new page anyway, it is better to just get the results like I mentioned early, with fopen, curl or file...

 

I just replied to your PM

Link to comment
Share on other sites

Well it kinda does !

 

The checker on index.php uses the script trine kindly sorted for me and displays the results.

 

if you then submit a new number on the broadbandchecker.php page it uses the Ajax. Both are set to return their results in the same div so it looks like it is all the same.

 

 

Ad

Link to comment
Share on other sites

Rob, all you need to do is actually change the DOM document location and it will work, but you may have to script around browsers. So I made it look for a post from another page to invoque a new script to print out the same results.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated