Click to See Complete Forum and Search --> : Closin little window while data go to main
Ipsens
August 30th, 2006, 07:22 PM
Ok, when in normal - main browser window I click on a link to display table data in a new window 400*400 which is opened by JavaScript....
This is a last cell in a row which is in 400*400 small window opened by JS
<td width="73" align="center" valign="middle" class="table_link_b"><form method="post" action="mod_site.php" target="_blank">
<input name="name" type="hidden" id="name" value="'.$sites[0].'" />
<input name="surname" type="hidden" id="url" value="'.$sites[1].'" />
<input name="surname" type="hidden" id="cr" value="'.$sites[4].'" />
<input name="surname" type="hidden" id="cph" value="'.$sites[5].'" />
<input name="surname" type="hidden" id="ws" value="'.$sites[6].'" />
<input type="submit" id="submit" class="table_link_a" onclick="window.close();" value="Modify" /></form></td>
Now as you can see I'm partiallly successfull in my goal.
Code above closes that small window and transfer data to new default browser window.
Now what I would like to achive is when I click modify in small window, then it must close and data should be transfered to a default browser instead opening blank new (so I end up with 2 of them).
Thanks in advance!
Ipsens
PeejAvery
August 30th, 2006, 11:21 PM
I am confused in two way.
1. What exactly are you trying to do? It seems a bit difficult to grasp without a diagram or small screenshot.
2. You are asking a lot of help. It is almost step by step. If you are unable to code this, why are you undertaking such a big task. It seems like you are trying to get the people at CG to code your app part by part.
cherish
August 31st, 2006, 03:19 AM
I would also like to add two more things:
1) This is more of a client-side scripting (Javascript) and not server-side. You should have created this thread in that forum. :)
2) When you say "default browser", you meant the original window that opened your 400*400 small window thru Javascript, right? If so, the reason why you're having two windows open is because of the target="_blank" in your <form> in the 400*400 "child" window. Try changing it to: target="_parent"
Just my two cents. :) Regards.
Ipsens
August 31st, 2006, 10:16 AM
When you say "default browser", you meant the original window that opened your 400*400 small window thru Javascript, right?
Yes! That is absolutely right.
....two windows open is because of the target="_blank" in your <form> in the 400*400 "child" window. Try changing it to: target="_parent"
I've tried to change it to ALL kind of possible target types
Only target="_blank" worked.
target="_parent", target="_self" obviously works with frames only.
...2. You are asking a lot of help. It is almost step by step. If you are unable to code this, why are you undertaking such a big task. It seems like you are trying to get the people at CG to code your app part by part.
Yes, task is big!
Script is already 1.14MB big (without flash part)
There are 2 types of questions I'am askinkg? PHP and JS type.
Regarding PHP, I post questions and answer them by myself before anybody answers(mainly...).
I only at the end ask for explenation of faulty example, so I could be more flexibile in a future in PHP.
PHP is my territory. I code 95% of it, all alone.
That is unless I stumble upon JS in prosess of programing...
When I started learning, "experienced one" told me that JS is waste of time because everything JS can, PHP can as well and MORE!
Well he was right except that some things that JS can PHP can't do!
Point is all my questions are bassed around JS.
So step by step is JS only.(But I'am figuring it out in a process)
I can't start learning it until I finish my script.
...(which is close to an end)
So back to a topic... How do I .........
Mitsukai
August 31st, 2006, 10:56 AM
you cant compare JS to PHP they are2 completly diffent things
Suril
August 31st, 2006, 12:32 PM
Hi, I got you completely
You want to popup a New Window with Javascript Where you will have a form, whose value shuld be passed to your parent window and close the poped Window. I feel this is what you want.
Well Lets see the overview
in this senerio, we will need two files.
1. parent.php
<script language="JavaScript">
<!--
window.name = 'Main';
function PopWin(file,lt,tp,Iwidth,Iheight,scrl)
{var = newWin1=window.open(file,'','x=0,y=0,toolbar=no,location=no,directories=no,status=no,scrollbars='+scrl+', copyhistory=no,width='+Iwidth+',height='+Iheight+',screenX=0,screenY=0,left='+lt+',top='+tp+',resize=no');
} -->
</script>
<a href="javascript:PopWin('Temp.asp',100,100,400,400)">Popup Modification Window</a><br><?php echo $_POST["txt"]; ?>
2. popup.php
<script language="Javascript">
function submitform()
{window.MyForm.submit();
window.close();
}
</script>
<form name="MyForm" method="post" action="results.asp" target="Main" onSubmit="javascript:submitform()">
<input type="text" name="txt" value="Try This" size="20"/><input type="submit" value="Modify"/>
</form>
Please Create this file and Try it.
What happens actually?
In parent.php
When we popup a new window with Javascript, *The window Poped* itself is "_parent" frame bcoz we are calling a function to popup and not HTML.
Thus we need to name the parent.php window as "Main" (see line 3 in parent.php)
3. window.name = 'Main';
I hope its clear upto this.
Clicking on "Popup Modification Window" opens popup.php in 400*400 window, fine?
In popup.php
See the Form Tag and Attribute, we have used target = "Main", this will post the form in the 'Main' frame which here is our parent.php and so the form is posted to opened parent.php
<form name="MyForm" method="post" action="results.asp" target="Main" onSubmit="javascript:submitform()">
See the onSubmit event of Form, its Javascript Function submitform(). This will just submit the form and close the popup window.
<script language="Javascript">
function submitform()
{
window.MyForm.submit();
window.close();
}
</script>
Hope this solved you purpose. Well if you have any more queries on this feel free to ask.
Regards
Suril :)
Ipsens
August 31st, 2006, 09:14 PM
Thanks Suril!
Looking at your code I took only 2 lines of code.
One to each window.
In parent.php, I've put:
window.name = 'main';
And in a small pop up window I changed target="_blank" to target="main"
and voila!
Nothing more I needed to alter.
Suril
September 1st, 2006, 01:10 AM
Ye i was going to tell you only that part, but the idea was to provide the whole concept to the guests who visit this thread. They would clear the concept with just two simple files.
Anyway i feel great helping you.
thank you, actually bcuz
if u wud ve not asked this que, i was gonna post this que. But as it was there. I searched for this, and deviced this. I actually learnt besides merely copying the code. Thanks in this concern
Regards
Suril
cherish
September 1st, 2006, 09:14 PM
Goes to show that there are a lot of info out there on the web, only if you're patient to search for it. Good job, Suril. :thumb:
HanneSThEGreaT
September 8th, 2006, 03:37 AM
When I started learning, "experienced one" told me that JS is waste of time
Are you sure the "experienced one" is indeed experienced. If he was so much "experienced", he should have know better.:D
Mitsukai
September 30th, 2006, 05:33 AM
js and php and html need eachother to make a great site. none of them are the same and are not comparible to eachother. js is not completly neccesary but it can give usefull fetures that makes it a better navigatible site
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.