View Full Version : Form Question

03-05-2005, 10:45 AM
I've added a search form to my site, but I want it to open a new window when you hit the "go" button. I tried just adding target="_blank" to the code, but it dinnae work. Why dinnae it work? ;_;

03-05-2005, 11:54 AM
I think target="_blank" only works in anchor tags, and not in form submit buttons, as far as I know :p

03-05-2005, 12:25 PM
Obviously, otherwise it would have worked when I did it.

That's two threads in a row you didn't immediatly solve my problem. You're losing your touch!

03-05-2005, 12:42 PM
Use JavaScript to open a new window onClick:

Flying Mullet
03-05-2005, 02:55 PM
Munty didn't solve the problem?

My world is crumbling around me...

03-05-2005, 11:39 PM
Alright, maybe I'm just too tired but, Raf, what do I change this button code to to make the java opening crap work?

<*input type="image" border="0" value="Go" name="Submit" src="ap-search-go-btn.gif"align="absmiddle" width="21" height="21" />

03-06-2005, 12:23 AM
<*input type="image" border="0" value="Go" name="Submit" src="ap-search-go-btn.gif" align="absmiddle" width="21" height="21" onClick="window.open('<i>yourpage</i>.html','mywindow','width=<i>width</i>,height=<i>height</i>')" />

<i>yourpage</i> is the filename of the page you want to open in the new window.
<i>width</i> and <i>height</i> are the, well, desired width and height of the javascript-generated window :p
I wouldn't pay attention to the "mywindow" part. It's the name of the window, and it's probably not a big deal for what you're using it for. You can change it to whatever you want.

03-06-2005, 12:56 AM
That's the thing. I don't know what to put for your page. Its an Amazon.com search field, so I'm not opening a particular page, its submitting a search.

03-06-2005, 01:07 AM
So the <*form action="something that's hosted on Amazon" />, and you want the search results to open in a new window? I'm not sure if you can do that, because the search results page is actually the script in the <i>action</i> property of the <i>FORM</i> tag. You may have to mess with the <i>FORM</i> and not the <i>INPUT</i> tag. You could try substituting <i>yourname</i> with the name of the script (it's linked to in < FORM action="<i>script</i>" ). That probably made next to no sense.

Try posting the code from < form> to </ form> so we can look through it. I think whether the results are opened in a new window is controlled within the actual script. Hopefully I'm just missing something really simple and obvious. Sorry I couldn't be of more help.

03-08-2005, 12:26 AM
Here's what Amazon gave me:


03-08-2005, 10:08 AM
I looked at your site since that bit of code is unhelpful :p
Try changing <*form action="http://www.amazon.com/exec/obidos/external-search"> into <*form action="http://www.amazon.com/exec/obidos/external-search" target="_blank">

03-08-2005, 11:13 AM
That's what I was going to suggest, but I figured the target property wasn't (and probably isn't) applicable to the FORM tag.

I too had a look at the frame source, and nothing helped. I looked around Amazon for a section about their site searches, but I couldn't find anything. Maybe there's a hidden input type that controls whether the form opens in a new window?

03-08-2005, 03:17 PM
You can use target in a form tag. Example:
&lt;form action="usercp.php?" target="_new">
&lt;input type="submit" value="Open the User CP in a new window">
<form action="usercp.php?" target="_new">
<input type="submit" value="Open the User CP in a new window">

03-08-2005, 10:08 PM

I suppose I could have just tested it instead of wondering :p .

03-10-2005, 04:34 AM
RAF WINS! *does a dance*

03-10-2005, 10:24 AM
It opens in a new tab for me :{

03-10-2005, 11:12 AM
Using Firefox and I get a new window =/. Have any custom extensions that might affect that?

*dances too*

03-10-2005, 12:38 PM
Yes, I do have an extension which makes it do that, but that's not the point :p