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

Search Code Adds Results to Results Page Instead of Replacing

Status
Not open for further replies.

thunderain

Programmer
Jan 10, 2002
40
CA
Hi

My problem is that I have Frames, with a javascript search function. The Search form is in the top
frame, with results appearing in the body frame. The first search works great, but when you do
a second search, it adds the second results to the bottom of the first results. I need the page
to refresh with only the second results appearing in the body frame, replacing the first results.

These 2 lines are putting my results into the body frame:
win = parent.frames["main information"]
win.document.write(page)

I have tried a replace line to no avail (variations)
window.location.replace( page );
window.location.replace( txt );

But this is knocking out my top frame, not my body frame. Can anyone tell me how to refresh the
body frame with the new results instead of adding them to the previous results? Is there a flaw in
the code somewhere below?


Here is my frameset with the 3 frames

<frameset rows=&quot;120,*&quot; border=&quot;0&quot; framespacing=&quot;0&quot; frameborder=&quot;no&quot;>
<frame src=&quot;topindex.html&quot; name=&quot;top main bar&quot; noresize scrolling=&quot;no&quot;>
<frameset cols=&quot;120,*&quot; border=&quot;0&quot; framespacing=&quot;0&quot; frameborder=&quot;no&quot;>
<frame src=&quot;filtran/sidebar.html&quot; name=&quot;side menu&quot; scrolling=&quot;no&quot; noresize>
<frame src=&quot;indexbody.html&quot; name=&quot;main information&quot; noresize>
</frameset>
</frameset>
<frameset rows=&quot;&quot; border=&quot;0&quot; framespacing=&quot;0&quot; frameborder=&quot;no&quot;>

</frameset>

Here is my search/show funtions:

function search(frm)

{



win = parent.frames[&quot;main information&quot;]

win.document.write(page)



txt = frm.srchval.value.split(&quot; &quot;);

fnd = new Array(); total=0;

for (i = 0; i < item.length; i++)

{

fnd = 0; order = new Array(0, 4, 2, 3);

for (j = 0; j < order.length; j++)

for (k = 0; k < txt.length; k++)

if (item[order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != &quot;&quot;)

fnd += (j+1);

}

for (i = 0; i < fnd.length; i++)

{

n = 0; w = -1;

for (j = 0;j < fnd.length; j++)

if (fnd[j] > n) { n = fnd[j]; w = j;

}

if (w > -1) total += show(w, win, n);

fnd[w] = 0;

}

win.document.write(&quot;</table><br>Total found: &quot;+total+&quot;<br></body></html>&quot;);

}

function show(which,wind,num)

{

link = item[which][1] + item[which][0];

line = &quot;<tr><td><a href='&quot;+link+&quot;'>&quot;+item[which][2]+&quot;</a> Rating: &quot;+num+&quot;<br>&quot;;

line += item[which][4] + &quot;<br>&quot;+link+&quot;</td></tr>&quot;;

wind.document.write(line);

return 1;

}

Any help or suggestions apprecieated

Thank you
Thunderain
 
Maybe
Code:
win = parent.frames[&quot;main information&quot;];
win.document.write(page);
win.document.close();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top