Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Iframe src + variable syntax problem

Status
Not open for further replies.

cbsarge

IS-IT--Management
Jun 20, 2001
219
US
I've got a page where a user inputs a value into a form and the results are listed in an iframe. I can't get the syntax right for the results. It just comes up like it searched for the word searchvar.

Thanks for the help!
Code:
<iframe src='[URL unfurl="true"]http://search.mysite.com/search?p="[/URL] + searchvar + "' width='100%' height='400'>

[!]The AutoSavers![/!] [2thumbsup]
 
Would you not target your form action to the name of the iframe? That is usually how you send data to a frame:
Code:
<form action="[URL unfurl="true"]http://search.mysite.com/search"[/URL] method="get" target="myIframeName">
...
</form>
<iframe src="about:blank" width="100%" height="400" name="myIframeName"></iframe>

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
The searchvar results will actually be displayed in 4 different iframes, each one searching a different url and data source. I need the submit of the search form to spawn the search results in all 4 frames. The frames will already be displaying " and then the next one will be " and so on. When the searchvar variable is submitted it will redraw these iframes withthe new value of searchvar added to the end of the url to display the results.

Can the form action be used to target 4 separate iframes?

something like:
Code:
document.frm.action='[URL unfurl="true"]http://search.site1.com/search?p="[/URL] + searchvar + "' method="get" target="a">";
	  document.frm.action='[URL unfurl="true"]http://search.site2.com/search?p="[/URL] + searchvar + "' method="get" target="b">";
	  document.frm.action='[URL unfurl="true"]http://search.site3.com/search?p="[/URL] + searchvar + "' method="get" target="c">";
	  document.frm.action='[URL unfurl="true"]http://search.site4.com/search?p="[/URL] + searchvar + "' method="get" target="d">";
	  document.frm.submit();

[!]The AutoSavers![/!] [2thumbsup]
 
No, but you can use Javascript to send the search parameter to all 4 frames and then refresh them so they perform the search.

Of course this falls outside the scope of this forum.

But I'm sure the guys over at: forum216 will be happy to help.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I just have to say that your code seems to be extremely convoluted and using both javascript and frames to achieve your result means you're alienating a lot of browser that cannot display one or another. I wonder if you should rethink how the results are shown.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Lol - very true.

I know my code is usually pretty messy. I'm not a programmer, I'm just messing around and seeing if I can get functions to work that I think up. If the people on me LAN at work are the only ones that end up using this (all IE7) then that's o.k..

Thanks for the critique though.

[!]The AutoSavers![/!] [2thumbsup]
 
My wierd code not withstanding, can someone tell me why when the iframe is drawn it interprest the variable named "searchvar" as the search term and not as a variable? In the line below, what should the correct syntax be to treat searchvar as a variable?

Code:
<iframe src="[URL unfurl="true"]http://search.site1.com/search?p='searchvar'"></iframe>[/URL]

[!]The AutoSavers![/!] [2thumbsup]
 
You're just outputting html attribute and putting some text in quotes. There's no variables in html, so any text in src is treated as plain text.

You need to involve javascript somehow. I recommend doing some unobtrusive thing, where you loop through the elements and change their src attribute appropriately. Guys at forum216 will be able to help you with that.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
cbsarge, I stumbled on your dialogue and found it interesting. Here is an example of how I worked it out some time back, if I understand your query correctly:

<SCRIPT language="JavaScript"
type="text/javascript">
<!--
function popemup( url ){
newWin = window.open(url,'','height=750,width=875,scrollbars=yes,left=270, top=50');
newWin.document.write("<head><title>"+ url +"<\/title><\/head>");
newWin.document.write("<iframe src=" + url + ">" +"<\/iframe>");
newWin.document.write("<p align=center>");
}
-->
</SCRIPT>
</head>
<body bgcolor=#ffffcd>
<center><h1>Passing URL's to Iframe Source</h1></center>
<p>&nbsp;
<p>&nbsp;<p>&nbsp;
<div align=center>
<table width=95%>
<tr>
<td width=33% align=center><a href="javascript:popemup(' </td>
<td width="*" align=center><a href="javascript:popemup(' </td>
<td width=33% align=center><a href="javascript:popemup(' Office</a> </td>
</tr>
</table>

It's a simple little table with links which pass the URL to the popup routine which builds and displays the page requested. This is not exactly what you were asking, but in your user's form you could pass the info via the OnClick, perhaps, in a similar fashion. Like vragabond says, you'll have get Javascript involved somehow to perform what you intend.
 
I see. Very good. I had slightly misunderstood what you were going for. You were passing search arguments to Iframes and then targeting frames across the bottom - an interesting approach. I developed my little routine for a different purpose - a page filled with links to videos, etc. which loaded into Iframes and which I redirected to a popup window for viewing. If I were doing what you did, I probably would have done something similar. Good job!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top