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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

target frame with search button

Status
Not open for further replies.

TripapHoniCs

Programmer
Sep 5, 2000
41
0
0
US
Hello all--

I will try to explain what I am trying to do as best I can. I have a search feature on an HTML based site. The search feature is javascript. The main page is in 3 frames, i.e. vHeader, right_frame & left_frame. The search button is in the vHeader page located at the top. The problem I am having is when I do a search and click the "search" button, the results refresh the browser window with the requested data...no more frames! I am trying to get the "search" button to display the results in the right_frame. Here is what I have thus far.


<HTML><HEAD></HEAD>
<BODY BGCOLOR=&quot;#A3B7C7&quot; LINK=&quot;#4F4F4F&quot; VLINK=&quot;#4F4F4F&quot;>
<table border='0' cellpadding='0' cellspacing='1'><TR><TD VALIGN='TOP'>
</TD><TD VALIGN='TOP'>


<A HREF=&quot;basket.htm&quot; target=&quot;right_frame&quot;>View Cart</A>


<A HREF=&quot;placeorder.htm&quot; TARGET=&quot;right_frame&quot;>Place Order</A>
</TD><TD VALIGN='TOP'>
<form name=&quot;search_form1&quot;>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;1&quot;>
<TR>
<TD><INPUT TYPE=&quot;text&quot; NAME=&quot;search&quot; SIZE=&quot;20&quot;></TD>
<TD><INPUT TYPE=&quot;button&quot; VALUE=&quot;Search&quot; onClick=&quot;javascript:top.doSearch(document.search_form1, document.search_form1.search.value)&quot;></TD></TR>
</TABLE></form>
</TD><TD VALIGN='TOP'>
</TD></TR></TABLE>
</BODY></HTML>

If someone could spell it out for me I would really appreciate it. Thanks

djTripapHoniCs. [sig][/sig]
 
I am hoping this is what you're talking about.


<HTML>
<HEAD>
<font color=&quot;#000000&quot; size=&quot;2&quot;></font>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--

function searchRec(itemNo, itemName, itemLink)
{
this.itemNo = itemNo;
this.itemName = itemName;
this.itemLink = itemLink;
}

//-->
</SCRIPT>

<script language=&quot;Javascript&quot; src=&quot;search.js&quot;></script>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--

function Searching(searchStr)
{
var d = document;
var t = top;
var bMatch = false;

d.writeln(t.checkoutFont);
d.writeln(&quot;<CENTER><STRONG>&quot; + t.lblSearchResults + &quot;</STRONG></CENTER><P>&quot;);
for (var i = 0; i < searchRecs.length; i++) {
var searchRec = searchRecs;
if (searchRec.itemNo.toLowerCase().indexOf(searchStr.toLowerCase(), 0) != -1 ||
searchRec.itemName.toLowerCase().indexOf(searchStr.toLowerCase(), 0) != -1) {
var line = &quot;&quot;;
var linkName = &quot;&quot;;
bMatch = true;
if (searchRec.itemNo == &quot;&quot;)
linkName = searchRec.itemName;
else
linkName = &quot;(&quot; + searchRec.itemNo + &quot;) &quot; + searchRec.itemName;
line += &quot;<STRONG>&quot; + linkName.link(searchRec.itemLink) + &quot;</STRONG><BR>\n&quot;;
}
}
if (!bMatch) d.writeln(&quot;<CENTER><STRONG>&quot; + t.lblSearchNoMatch + &quot;</STRONG></CENTER>&quot;);
}
document.writeln(&quot;<HTML><BODY BGCOLOR=\&quot;#A3B7C7\&quot; >&quot;);
document.writeln(&quot;Searching...&quot;);
Searching(top.keywordSearch);
document.writeln(&quot;</BODY></HTML>&quot;);
document.close();


//-->
</SCRIPT>
<font color=&quot;#000000&quot; size=&quot;2&quot;></font>
</HEAD>
<BODY>
</BODY>
</HTML>

I hope that helps. [sig][/sig]
 
The first thing I posted was all the code for the vHeader file, or &quot;top&quot; file. There is a <INPUT TYPE=&quot;button&quot; VALUE=&quot;Search&quot; onClick=&quot;javascript:top.doSearch(document.search_form1, document.search_form1.search.value)&quot;> that was in the first thing I posted. If that's not it, I don't know what you're talking about. sorry for the confussion. [sig][/sig]
 
Hmmmm...just for the fun of it, try removing 'javascript:top.' from your onClick event so it's like this:

<INPUT TYPE=&quot;button&quot; VALUE=&quot;Search&quot; onClick=&quot;doSearch(document.search_form1, document.search_form1.search.value)&quot;>

I'm not sure what your problem is, but just a hunch there. If that doesn't work, look inside your include file search.js for a function named doSearch() (if you can't find it anywhere else) and post that.

HTH,

[sig]<p>Russ<br><a href=mailto:bobbitts@hotmail.com>bobbitts@hotmail.com</a><br><a href= is in</a><br>[/sig]
 
Is changing that going to specify the target frame to be right_frame? That is where I want the product of the search to end up, in the right_frame. [sig][/sig]
 
Actually I'm not sure. My confusion comes from that statement that I asked you to remove. My first impression was that 'top' referred to the frame name, but I'm beginning to think that it may be causing you to break out of your frames.

Just try it, if it screws up things worse or doesn't work, just put it back. [sig]<p>Russ<br><a href=mailto:bobbitts@hotmail.com>bobbitts@hotmail.com</a><br><a href= is in</a><br>[/sig]
 
ok..tried it...error. The js file is the following

var searchRecs = new Array();
searchRecs[0] = new searchRec(&quot;000076&quot;,&quot;Table Vases&quot;,&quot;item81.htm&quot;);
---a whole bunch of products like the one just listed, and that's it. [sig][/sig]
 
A runtime error has occured. Line 15. the line that we took javascript:top. off of. [sig][/sig]
 
Ok, I took a look. I think it might have to do with fact that you have nested framesets and (for some reason) the browser thinks you're referring to the entire bottom frameset. Here's the function that actually changes the page, so the problem would seem to originate here:

function doSearch(f, searchString)
{
if (searchString != &quot;&quot;){
f.search.value = &quot;&quot;;
top.keywordSearch = searchString;
top.contentFrame.location = &quot;search.htm&quot;;
}
}

The problem is top.contentFrame.location=&quot;search.htm&quot; is destroying your bottom frames and replacing them with the contents of the target.

The only thing I can think of to try is this:

function doSearch(f, searchString)
{
if (searchString != &quot;&quot;){
f.search.value = &quot;&quot;;
top.keywordSearch = searchString;
parent.frames['contentFrame'].location = &quot;search.htm&quot;;
}
}

Give this a try and see if it works. I'm laughing here because I have the feeling there's something obvious that we're both missing and (after 500 posts), somebody will finally come along and answer your initial question in a sentence.
[sig]<p>Russ<br><a href=mailto:bobbitts@hotmail.com>bobbitts@hotmail.com</a><br><a href= is in</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top