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!

Search - one popup 3

Status
Not open for further replies.

LittleRedHat

Instructor
Apr 20, 2001
202
GB
I'm using a form search. (code extract below) It works fine and it's ok that the pages load in the same window ... except I would like just the map to load in a new popup window. Is it possible?

<form name="search" id="search">
<select name="search">
<option value="index.htm">Quick Search</option>
<option value="map.htm">Map</option>
<option value="pots_chinese.htm">Pots: Chinese</option>
<option value="tools_sundries.htm">Sundries</option>
<option value="trees_mature.htm">Trees: Mature</option>
<option value="diary.htm">Workshop Diary</option>
</select>
<input name="search_go" type="button" id="search_go" onclick="location=this.form.search.options[this.form.search.selectedIndex].value;" value="GO" />

WTA
LRH
 
Try:

onclick="window.open(this.form.search.options[this.form.search.selectedIndex].value,'','');"

Lee
 
There was a thread on this recently - in fact, it's still on the first page of this forum. It shows exactly how to target a form submission to a popup window. Maybe you didn't try the search facility?

"how to delegate a form's submit to a new window to be opened?" (thread216-1187087)

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi Lee & Dan

Thank you for your suggestions ... and btw Dan I did spend considerable time searching b4 I asked the question as I don't believe in wasting good folks' time. I did turn up the thread you mentioned, but didn't see how it could resolve my problem. Perhaps I'm just being dim and admit to being very javascript rusty!

I'm still having the problem that either all pages load as popups or all pages load in the same window. I've tried innumerable ways without success to have the code read "if the selection is 'map' open in new window, else open the rest in the same window."

Any further suggestions would be very appreciated.

WTA
LRH
 
Hi again!

Seems the answer to my original question is probably "No" so am going for writing a function.

With thanks again for your interest.

Cheers ...

LRH
 
LittleRedHat, this is an easy change to make.
Your button currently directly alters the location.
Instead, make the button call a function passing the value.
Test the value and if it is Map then you open a popup and anything else changes the location.
Like this:

Code:
<input name="search_go" type="button" id="search_go" onclick="pagechange(this.form.search.options[this.form.search.selectedIndex].value;)" value="GO" />

Then add in a function like this:
Code:
function pagechange(where)
{
  if (where == 'map.htm')
    window.open(map.htm,'','');" 
  else
    location=where;
}

I have not actually tested this code but it should be pretty close if not directly usable.


Stamp out, eliminate and abolish redundancy!
 
Thanks NiteOwl,
Works very well - only slight problem
Code:
window.open([COLOR=red]'[/color]map.htm[COLOR=red]'[/color],' ',' ');"

Those little ' make all the difference... Hope this helps

Cheers,
G2III
 
Hi Folks,

Thanks again, but I'm afraid I've not sorted the problem. :-(

I picked up your suggestion theniteowl (thanx) b4 I got round to writing my own, so gratefully went ahead and used yours as a base. I've tried endless variations, but it does nothing/no pages load.

function windowtype(choice)
{
if (choice == 'map.htm')
{
new_window=window.open('map.htm');
}
else
{
location=choice;
}
}
----------------------
<input name="search_go" type="button" id="search_go" onclick="windowtype(this.form.search.options[this.form.search.selectedIndex].value;)" value="GO" />
----------------------
I seem to have run into a total mental block over this and I'd really appreciate any new advice you have to offer if you have time.

WTA
LRH

And my compliments, Dan ... the work on your site is very impressive.
 
Try removing the semicolon from after "value" , and putting it after the bracket instead. So from this:

Code:
onclick="windowtype(this.form.search.options[this.form.search.selectedIndex].value[!];[/!])"

to this:

Code:
onclick="windowtype(this.form.search.options[this.form.search.selectedIndex].value)[!];[/!]"

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
The op's problem is that they have a name collision. Form element is named "search", and select-one element is also named "search". Rename the form to something else like "searchform" so that the onclick can be kept the same.
 
I didn't think that would be a problem, given that "this.form" refers to the form, and so "this.form.search" would refer to the search element inside the form, not the form itself.

But certainly worth looking into.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
This works for me.
Code:
function windowtype(choice)
{
  if (choice == 'map.htm') 
  {
    new_window = window.open('map.htm','','');
  }
  else 
  { 
    location=choice;
  }
}

Stamp out, eliminate and abolish redundancy!
 
Hi Guys,

:) It was the semicolon, Dan. I thought I'd checked all the ; () ' & " 's, but obviously missed the crucial one.

Apols 4 not getting back sooner, but at 3.00 am I wasn't only not able to see the wood, I couldn't even see the trees and surrendered.

Thanx theniteowl for the starter for 10
Thanx Dan for staying with me and resolving the error of my ways.
Thanx tsuji for your suggestion. I'd wondered about that too and had tried changing names.
Thanx G2 - every little helped.

Best wishes to you all ...
LRH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top