Forum Moderators: open

Message Too Old, No Replies

IFRAME and FORM question

iframe, form handling procedures, post

         

MarkC

5:37 pm on May 16, 2003 (gmt 0)

10+ Year Member



Can anyone help, as I am trying something new (to me) here. I know it can be done!
I have a page that has an iframe. Within the iframe is the content of a search facility (which uses asp). The search facility is on an external site which I have no control over. Let's call my own page search.htm and the external site www.abc.com/search.asp
I would like to be able to have a small field/submit section on every page of my site that would submit the search details to the external site, then bring up the results within the iframe in search.htm.
Can this be done? I am assuming I will have to assign values to the iframe and set some variable within the POST function, but frankly, it's all starting to go over my head.

Could anyone help?
Mark

dmorison

5:53 pm on May 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

If the search engine you want to control uses GET to process its query input then you could use JavaScript to do this.

You need to figure out the format of the URL that the search engine you are linking to uses when you submit a query.

For example, to search Google, the URL is:

[google.com...]

The following code displays an IFRAME and your own edit box, from which you can submit a query directly to Google, which then opens up in the IFRAME:


<script type='text/javascript'>

function GoGoogle()
{
document.all.googleframe.src='http://www.google.com/search?q='+document.all.s.value;
}

</script>

<iframe id='googleframe' width='400' height='200' src='http://www.google.com/'></iframe>

<br><br>

<input type='text' name='s'>

<input type='button' value='Search' onclick='javascript:GoGoogle();'>

Of course you don't need to use an edit box and button, but this code should give you the mechanics of what you need to do.

Hope this helps!

MarkC

8:49 pm on May 16, 2003 (gmt 0)

10+ Year Member



Thanks - I'll have a go...
The external url always looks like this after a submission
(in this case for 74hct245)
[abc.com...]
I'll try the JS option and post back here when I see what happens...thanks once again!

MarkC

7:53 am on May 19, 2003 (gmt 0)

10+ Year Member



Hmm, looks like the site uses the POST function to do the search.

I think this is probably getting a bit too tricky for my little brain...certainly tried the above but no luck.

I'm pretty sure that I should be calling the search.htm page within my site from the form (search box) that I intend to have on every page. The difficulty is surely posting the info to the external site, then calling the search.htm page within my site with the results already there in the iframe.

I'm also sure that I need to give the iframe an ID or name in order to be able to carry out this order.

However, I then begin to lose track of what's going on! I thought HTML was supposed to be easy... :(