Adamski Posted May 23, 2007 Share Posted May 23, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 that will depend firstly on the function name being correct, and secondly on your script. can you provide more info, and I can have a go. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 script is here javascript for ajax is here Thanks, Adam [edit] links removed [edit] 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 Looks like your innerHTML may not be set? do you have a dive or element with the id "results" on the page? 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 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! 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 okay, I see ... you are getting header errors too. ... still checking 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 you will need to add this to your index.php: <div id="Results"> </div> 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 I'll check the header error out.. thanks for that. If I add that div on the index page the results will be displayed their and not on the broadbandchecker.php page. 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 oops, I misread your post. one more moment 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 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] 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 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 } 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 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... 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 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]; ?> 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 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. 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 PM me if you need me to write a quicky script for you. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 Script sent! 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 Big thanks to trine for helping me out on this one. I know have a working script .. phewph 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted May 23, 2007 Share Posted May 23, 2007 I know have a working script .. phewph I'd be interested in seeing the finished code if you have it working now - especially if its retaining the ajax methdos - just playing with something similar myself. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 23, 2007 Share Posted May 23, 2007 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. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted May 23, 2007 Author Share Posted May 23, 2007 Much better said trine 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted May 23, 2007 Share Posted May 23, 2007 I can see the checker working on broadbandchecker.php - am more interested in how you're going to parse the results and take themonto the right product(s) in WHMCS 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.