473,386 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

pop up once

Hi,

can any one help me to create the pop up only once. on clicking the text box

[HTML]<html>
<head>
<script type="text/javascript">
function abc()
{
var wind1=null;
var tmp=null;
wind1 = window.open('', 'displayWindow', 'width=400,height=300,status=no,toolbar=no,menubar =no,scrollbars=no');
wind1.document.write("<script> function alert1(f){");
wind1.document.write("var frmdst=f.ta.value;");
wind1.document.write("window.opener.tmp=frmdst;");
wind1.document.write("window.opener.getValues();") ;
wind1.document.write("window.close();");
wind1.document.write("}<\/script>");
wind1.document.write("<html><body><form action='#' name='myform' method='post'><TEXTAREA rows='2' cols='20' name='ta'></TEXTAREA><br><INPUT type='button' value='save' onclick='javascript:alert1(this.form);'><INPUT type='button' value='cancel' onclick='javascript:window.close();'></form></body></html>");
}
function getValues()
{
document.forms["source"].elements["srctext"].value = tmp;
}
</script>
</head>
<body>
<form action="#" name="source" method="get">
<input type="text" onclick='abc();' name="srctext" value="" size="20" />
</form>
<body>
</html>[/HTML]
Feb 28 '08 #1
13 1988
gits
5,390 Expert Mod 4TB
just use a variable:

Expand|Select|Wrap|Line Numbers
  1. var run = 0;
  2.  
when you click open the popup and set run to 1 ... in the open-window code check for run == 0 otherwise simply return from the opening function ...

kind regards
Feb 28 '08 #2
just use a variable:

Expand|Select|Wrap|Line Numbers
  1. var run = 0;
  2.  
when you click open the popup and set run to 1 ... in the open-window code check for run == 0 otherwise simply return from the opening function ...

kind regards
Thanks alot..I tried it but after I am clicking cancel i am unable to get the popup again.
Feb 29 '08 #3
gits
5,390 Expert Mod 4TB
since you didn't tell that that is a requirement this should be true :) ... just set the variable run in the opener back to 0 when you click cancel in your popup :)

kind regards
Feb 29 '08 #4
hsriat
1,654 Expert 1GB
Try setting the value of run as 1 or 0 on click of the OK or Cancel (respectively) of the pop up window.
Feb 29 '08 #5
gits
5,390 Expert Mod 4TB
Try setting the value of run as 1 or 0 on click of the OK or Cancel (respectively) of the pop up window.
yup that would be a more straight way for the entire handling :)

kind regards
Feb 29 '08 #6
Thanks!

Can you please help me to write the code for resetting the value on Clicking "cancel" or "save".

I think its not working as its a global variable.


Regards.
Feb 29 '08 #7
gits
5,390 Expert Mod 4TB
in your popup use:

Expand|Select|Wrap|Line Numbers
  1. window.opener.run = 1;
  2.  
onclick of save and set it to 0 when cancel is clicked.

kind regards
Feb 29 '08 #8
its still not working ...can you please rectify the errors.

here is the code

[HTML]<html>
<head>
<script type="text/javascript">
var run=0;
function abc()
{
if(run==0)
{
var wind1=null;
var tmp=null;
wind1 = window.open('', 'displayWindow', 'width=400,height=300,status=no,toolbar=no,menubar =no,scrollbars=no');
wind1.document.write("<script> function alert1(f){");
wind1.document.write("window.opener.run = 1;");
wind1.document.write("var frmdst=f.ta.value;");
wind1.document.write("window.opener.tmp=frmdst;");
wind1.document.write("window.opener.getValues();") ;
wind1.document.write("window.close();");
wind1.document.write("}<\/script>");
wind1.document.write("<html><body><form action='#' name='myform' method='post'><TEXTAREA rows='2' cols='20' name='ta'></TEXTAREA><br><INPUT type='button' value='save' onclick='javascript:alert1(this.form);window.opene r.run = 0;'><INPUT type='button' value='cancel' onclick='javascript:window.close();window.opener.r un = 0;'></form></body></html>");
}

}

function getValues()
{
document.forms["source"].elements["srctext"].value = tmp;
}

</script>
</head>
<body onload="">
<form action="#" name="source" method="get">
<input type="text" onclick='abc();' name="srctext" value="" size="20" />
</form>
<body>
</html>[/HTML]
Feb 29 '08 #9
Thanks alot...!

its working now.:)
Feb 29 '08 #10
gits
5,390 Expert Mod 4TB
hi ...

glad to hear that :) it seems that you had set the variable to 0 in both of the cases? ...

one note:

just use:

Expand|Select|Wrap|Line Numbers
  1. onclick='window.opener.run = 0;'
the javascript: is useless today ...

kind regards
Feb 29 '08 #11
Thanks a lot...! :)
Feb 29 '08 #12
hsriat
1,654 Expert 1GB
the javascript: is useless today ...
.... unless you have to call a JavaScript function in an href attribute.
Feb 29 '08 #13
acoder
16,027 Expert Mod 8TB
.... unless you have to call a JavaScript function in an href attribute.
...which you shouldn't need to do unless it's a bookmarklet.
Feb 29 '08 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stuart A Yeates | last post by:
I'm trying to write a template that matches "*" but which has an if clause which if only executed once per type of element seen (where all elements of a type have the same name and namespace). The...
1
by: Jacob Jensen | last post by:
Hi I have a problem creating C++ code that is multiplatform compilable. My problem is using the "#pragma once" directive which can be used by microsoft Visual Studio pre-compiler but which gives...
2
by: Just Me | last post by:
When a document is to be printed I call a method that contains an AddHandler statement. I just realized that if a second copy is to be printed the method is called and the AddHandler is executed...
5
by: ShaunO | last post by:
BACKGROUND I have the following classes as part of a program that opens 3 Asynchronous Sockets. Each socket is in a separate instance of a wrapping class. 1x User Interface class 1x Client...
5
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I have been using the Click Once deployment feature of VS2005 - very nice. I had IE6 at the time when I started using Click Once Deployment, and everything worked fine. But then my...
10
by: Lorenzo Di Gregorio | last post by:
Hello, I've been using Python for some DES simulations because we don't need full C speed and it's so much faster for writing models. During coding I find it handy to assign a variable *unless...
29
by: Neil | last post by:
Running a SQL 7 system on a Windows 2000 server using Access 2000 on client machines as a front end. System administrator currently reboots the server once a month. Yesterday we had some weird...
26
by: Rick | last post by:
I'm told that "#pragma once" has made it into the ISO standard for either C or C++. I can't find any reference to that anywhere. If it's true, do any of you have a reference I can use? ...
5
by: raashid bhatt | last post by:
What is #pragma once used for and what is #WIN#@_LEN_AND_MEAN
4
by: Yonih | last post by:
Hey Yall, I am trying to incorporate a Once Per session Cookie that will expire once the browser is closed so some one who comes to my website will see my popup the first time her visits the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.