Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 855
  • Last Modified:

Open a page in the same window onchange of a select box

Hello,,


How do we open a page in the same window instead of a diff window on change of a selectbxo

function ChangeLocation(obj)
    {
     
   parent.window.location.href = 'add.aspx?cid=' + obj.options[obj.selectedIndex].value;
    }

If I call the above function onchange of a select box it is opening in a new window. I want this to open in the same page. How do we do this.

0
sureshraina
Asked:
sureshraina
  • 3
  • 2
  • 2
1 Solution
 
mvan01Commented:
Maybe use self.location.href =

Peace and joy.  mvan
0
 
Onyx23Commented:


You can try:


function ChangeLocation(obj)
    {
     
   self.window.location.href = 'add.aspx?cid=' + obj.options[obj.selectedIndex].value;
    }
0
 
Pravin AsarPrincipal Systems EngineerCommented:
If you trying to send to same window then following should update the link


window.location.href = 'add.aspx?cid=' + obj.options[obj.selectedIndex].value;


<form>
<select onchange="window.location.href=this.value;">
<option value="" selected>Select Option</option>
<option value="http://www.yahoo.com">Yahoo!</option>
<option value="http://www.msn.com">MSN!</option>
</select>
</form>

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mvan01Commented:
All listening here,

window and self are synonyms (within the current context).  Thus:

self.location.href

is the same as:

window.location.href

I don't believe self.window.location.href works, because that is like saying window.window.location.href, or self.self.location.href .  It will not work if window is not a method or property of window.

Peace and joy.  mvan

0
 
Pravin AsarPrincipal Systems EngineerCommented:
Look at my post.

window.location.href = 'add.aspx?cid=' + obj.options[obj.selectedIndex].value;

can be simplified to ( Look at the example code in previous post)

window.location.href = 'add.aspx?cid=' + obj.value;


Thanks,

_PA
0
 
mvan01Commented:
... and in http:Q_21854497.html#16703999 ,

"Maybe use self.location.href = "

clearly meant:

function ChangeLocation(obj) {
   self.location.href = 'add.aspx?cid=' + obj.options[obj.selectedIndex].value;
    }

which shall perform the same as:

function ChangeLocation(obj) {
   window.location.href = 'add.aspx?cid=' + obj.options[obj.selectedIndex].value;
    }

;-)

Peace and joy.  mvan
0
 
Onyx23Commented:
"I don't believe self.window.location.href works, because that is like saying window.window.location.href, or self.self.location.href .  It will not work if window is not a method or property of window."


That is TRUE good catch!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now