Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

onClick - open in same screen instead of new window

Posted on 2008-06-23
6
Medium Priority
?
2,132 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
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 Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
Suggested Courses

963 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