Solved

onClick - open in same screen instead of new window

Posted on 2008-06-23
6
2,119 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now