Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

onClick - open in same screen instead of new window

Posted on 2008-06-23
6
Medium Priority
?
2,128 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
LVL 11

Accepted Solution

by:
spoxox earned 500 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

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. …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

705 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