Solved

onClick - open in same screen instead of new window

Posted on 2008-06-23
6
2,124 Views
Last Modified: 2012-05-05
I have the following code:

<input name="Submit" onclick="ob=this.form.selectPistols;window.open(ob.options[ob.selectedIndex].value)" type="submit" class="style2" value="Search">

Which works - but opens in a new window. What's the syntax to navigate using the same browser window?

Thanks,
<form name="form2" method="post" action="">
          <select name="selectPistols" class="style2" id="selectPistols">
<%
While (NOT rsMansPistols.EOF)
%>
<option value="Results1.asp?Manufacturer=<%=(rsMansPistols.Fields.Item("ManufacturerID").Value)%>&Category=%&Keyword=&Submit=Search">
<%=(rsMansPistols.Fields.Item("Manufacturer").Value)%></option>
<%
  rsMansPistols.MoveNext()
Wend
If (rsMansPistols.CursorType > 0) Then
  rsMansPistols.MoveFirst
Else
  rsMansPistols.Requery
End If
%>
</select>
<input name="Submit" onclick="ob=this.form.selectPistols;window.open(ob.options[ob.selectedIndex].value)" type="submit" class="style2" value="Search">
</form>

Open in new window

0
Comment
Question by:globalwm
6 Comments
 
LVL 7

Expert Comment

by:Brad Dobyns, CSM
ID: 21851933
<a href='javascript:self.location.href="http://www.somesite.com/";'>

or

<a href='#' onclick='javascript:self.location.href="http://www.somesite.com/"; return false;'>
0
 
LVL 4

Expert Comment

by:sajay_j
ID: 21851973
Avoid   window.open  Statements...
0
 
LVL 4

Expert Comment

by:sajay_j
ID: 21851979
or try adding this line at top of the page

<base target="_self" />
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 11

Accepted Solution

by:
spoxox earned 125 total points
ID: 21852039
Change your submit button to type=button;
change window.open to location.href=

<input name="Submit"
onclick="ob=this.form.selectPistols;location.href=ob.value;"
type="button" class="style2" value="Search">
0
 
LVL 1

Author Comment

by:globalwm
ID: 21867679
Sorry, the <base target="_self" /> did not work and the <a href> solution I'm not sure how to use with a form button.

Trying the others - I think spoxox's might look promising. brb
0
 
LVL 1

Author Closing Comment

by:globalwm
ID: 31470015
Thanks - worked perfectly. I had never used this type of function before.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question