Solved

onClick - open in same screen instead of new window

Posted on 2008-06-23
6
2,125 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

738 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