thunderain
Programmer
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="120,*" border="0" framespacing="0" frameborder="no">
<frame src="topindex.html" name="top main bar" noresize scrolling="no">
<frameset cols="120,*" border="0" framespacing="0" frameborder="no">
<frame src="filtran/sidebar.html" name="side menu" scrolling="no" noresize>
<frame src="indexbody.html" name="main information" noresize>
</frameset>
</frameset>
<frameset rows="" border="0" framespacing="0" frameborder="no">
</frameset>
Here is my search/show funtions:
function search(frm)
{
win = parent.frames["main information"]
win.document.write(page)
txt = frm.srchval.value.split(" "
;
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] != ""
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("</table><br>Total found: "+total+"<br></body></html>"
;
}
function show(which,wind,num)
{
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Rating: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>";
wind.document.write(line);
return 1;
}
Any help or suggestions apprecieated
Thank you
Thunderain
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="120,*" border="0" framespacing="0" frameborder="no">
<frame src="topindex.html" name="top main bar" noresize scrolling="no">
<frameset cols="120,*" border="0" framespacing="0" frameborder="no">
<frame src="filtran/sidebar.html" name="side menu" scrolling="no" noresize>
<frame src="indexbody.html" name="main information" noresize>
</frameset>
</frameset>
<frameset rows="" border="0" framespacing="0" frameborder="no">
</frameset>
Here is my search/show funtions:
function search(frm)
{
win = parent.frames["main information"]
win.document.write(page)
txt = frm.srchval.value.split(" "
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] != ""
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("</table><br>Total found: "+total+"<br></body></html>"
}
function show(which,wind,num)
{
link = item[which][1] + item[which][0];
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Rating: "+num+"<br>";
line += item[which][4] + "<br>"+link+"</td></tr>";
wind.document.write(line);
return 1;
}
Any help or suggestions apprecieated
Thank you
Thunderain