• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Enabling a button

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a JSP page and on click of button A , a pop up window opens. When I click on the close button OR when I click on the pop up windows X to close the pop up OR when I click on the parent window, i want to enable a button B on the parent window( note- when I click on the parent window, the pop up automatically closes by itself).
Can anybody tell me how I can achieve this
Thx in advance
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
document.FormName.ButtonName.disabled = false;
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Eric
How do I handle the situation when the user doesn't close the pop up and simply clicks on the parent window.In this case too the button needs to be enabled(as the pop up closes automatically when i click on the parent window).
What if the user clicks on the browser close icon of the pop up window.How to handle this situation in addition to the above?
Mary
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys..pls reply its urgent
 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understood your problem correctly ,just check below example.
File : main.html
-------------------------
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function openChildWindow() {
child = window.open('popup.html','myWindow','toolbar=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,directories=yes,width=640,height=480');
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="parentFrm" >
<INPUT TYPE =button name="ABttn" value="A" event="javascript penChildWindow()"> <br><br>
<INPUT TYPE = button name="BBttn" value="B" DISABLED>
</FORM>
</BODY>
</HTML>
------------------
File : popup.html
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function enableButton()
{
opener.parentFrm.BBttn.disabled=false;
}
</SCRIPT>
</HEAD>
<BODY onUnload="enableButton()">
<FORM name=childFrm >
<INPUT TYPE = button name="clsBttn" value="Close" event="window.close()">
</FORM>
</BODY>
</HTML>
------------------
Hope this help.
Change word "event" to "onClick".It does not allow me to post if i use "onClick" word inside HTML.
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey himanshu,
Thx for ur reply.
Actually U guys didn't get my point.
2 scenarios are there
1)When the pop up is open and when i click on the pop up windows's close icon(browsers)
, the pop up window closes and automatically the parent windows button should be enabled
2)When the pop up is open, and when i click anywhere on the parent window , the popup should automatically close and enable the parent windows button
I need a script which satisfies these scenarios too

icon
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
himanshu gave you a great starting place. It will enable the button when the child is closed.

 
himanshu patel
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mary Cole:
Hey himanshu,
Thx for ur reply.
Actually U guys didn't get my point.
2 scenarios are there
1)When the pop up is open and when i click on the pop up windows's close icon(browsers)
, the pop up window closes and automatically the parent windows button should be enabled
2)When the pop up is open, and when i click anywhere on the parent window , the popup should automatically close and enable the parent windows button
I need a script which satisfies these scenarios too
icon


I think you haven't looked carefully at sample code.I am sure it does satisfies your first criteria.
Anyway, try this code and see does it satisfies your all criterias.
-----------------
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var child;
var flag=1;
function checkFocus(){
if(flag==1){
if (child && !child.closed){
child.close();
parentFrm.BBttn.disabled=false;
}
}else{
flag=1;
}
}
document.onclick = checkFocus;
if (document.captureEvents){
document.captureEvents(Event.CLICK);
}
function openChildWindow() {
child = window.open('popup.htm','myWindow','toolbar=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,directories=yes,width=640,height=480');
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="parentFrm" >
<INPUT TYPE =button name="ABttn" value="A" onclick="javascript penChildWindow()"> <br><br>
<INPUT TYPE = button name="BBttn" value="B" DISABLED>
</FORM>
</BODY>
</HTML>
---------------------
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
opener.flag=0;
</SCRIPT>
</HEAD>
<BODY onUnload="opener.parentFrm.BBttn.disabled=false;">
<FORM name=childFrm >
<INPUT TYPE = button name="clsBttn" value="Close" onclick="window.close()">
</FORM>
</BODY>
</HTML>
-----------------
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
whats the value which goes to the child variable.... I couldn't see any where how value is assigned to that variable
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i overlooked it..pls ignore my earlier reply
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic