From: Tony M. <to...@ht...> - 2005-02-06 03:06:15
|
I have a special project that I've been working on and I have been trying to create a sub popup window with javascript that I can use to do an update. I have been having a couple of problems... I was able to update the {START_FORM} tag on the template by using: if(isset($_REQUEST["lay_quiet"])) $tags["START_FORM"] = "<form action=\"index.php\" method=\"post\" name=\"editcigar\" onSubmit=\"return true;\">"; (I used the return true to simply test the onSubmit() which is not working) According to the javascript manual, you have to return true to the onSubmit() to make it submit the form, otherwise it simply "tosses" it. I was trying to use the onSubmit() to refresh the parent window, and close the sub form (pop-up). Any ideas on why this wouldn't work? Is there any better way to get extra information into the <form> tag? Thanks, -Tony -- Hometown Enterprises Internet Services Professional, affordable web design and hosting. http://www.hteis.com/ |
From: Steven L. <st...@tu...> - 2005-02-08 19:40:51
|
On Sat, 2005-02-05 at 22:06 -0500, Tony Miller wrote: > Any ideas on why this wouldn't work? I normally use the get DOM function getElementById() So you would do something like this: if(isset($_REQUEST["lay_quiet"])) $tags["START_FORM"] = "<form id=\"myformid\" action=\"index.php\" method=\"post\" name=\"editcigar\">"; Make sure you confirm this is properly making it into the html source. Then in the form template file at the bottom put: <script type="text/javascript"> //<![CDATA[ document.getElementById('myformid').onsubmit = function doSomething() { // whatever you gotta do // opener.document.reload(); // window.close(); return true; } //]]> </script> > Is there any better way to get extra information into the <form> tag? Currently there is not an easier way :( Hope this helps. Steven |
From: Tony M. <to...@ht...> - 2005-02-09 03:15:14
|
On Tue, 8 Feb 2005, Steven Levin wrote: > On Sat, 2005-02-05 at 22:06 -0500, Tony Miller wrote: > > Any ideas on why this wouldn't work? > > I normally use the get DOM function getElementById() > > So you would do something like this: > > if(isset($_REQUEST["lay_quiet"])) > $tags["START_FORM"] = "<form id=\"myformid\" action=\"index.php\" method=\"post\" name=\"editcigar\">"; > > Make sure you confirm this is properly making it into the html source. > > Then in the form template file at the bottom put: > > <script type="text/javascript"> > //<![CDATA[ > > document.getElementById('myformid').onsubmit = function doSomething() { > // whatever you gotta do > // opener.document.reload(); > // window.close(); > return true; > } > > //]]> > </script> Thanks for the suggestion, I seem to be hitting the javascript on submit, the window is closing, the parent form is refreshing, but the information is not being submitted. Here are snippets of the generated HTML. <form id="editcigarid" name="editcigar" action="index.php" method="post"> <input type="hidden" name="module" value="cigardiary" /> <input type="hidden" name="CC_OP" value="save" /> ... <script type="text/javascript"> //<![CDATA[ document.getElementById('editcigarid').onsubmit=function dropWindow() { window.opener.location.reload(true); window.close(); return true; } //]]> </script> It should be returning true to the "onsubmit" forcing it to submit the data to the server. So far in my travels I've been able to either 1. Save the data and not close the popup and refresh the parent window. 2. Close the popup and refresh the parent window but not save the data. > > Is there any better way to get extra information into the <form> tag? > > Currently there is not an easier way :( I don't care if it's easier, just so long as it works. I think I'm getting close with your help. > Hope this helps. It did help, but I'm not there yet. There's some interaction with onsubmit that I don't understand. Anyone with ideas, please speak up. -Tony -- Hometown Enterprises Internet Services Professional, affordable web design and hosting. http://www.hteis.com/ |
From: Steven L. <st...@tu...> - 2005-02-09 15:18:36
|
On Tue, 2005-02-08 at 22:14 -0500, Tony Miller wrote: > Thanks for the suggestion, I seem to be hitting the javascript on submit, > the window is closing, the parent form is refreshing, but the information > is not being submitted. Here are snippets of the generated HTML. > > <form id="editcigarid" name="editcigar" action="index.php" method="post"> > <input type="hidden" name="module" value="cigardiary" /> > <input type="hidden" name="CC_OP" value="save" /> > > ... > > <script type="text/javascript"> > //<![CDATA[ > > document.getElementById('editcigarid').onsubmit=function dropWindow() { > window.opener.location.reload(true); > window.close(); > return true; > } > > //]]> > </script> > > It should be returning true to the "onsubmit" forcing it to submit the > data to the server. > > So far in my travels I've been able to either > > 1. Save the data and not close the popup and refresh the parent window. > > 2. Close the popup and refresh the parent window but not save the data. Try doing this instead of using the onsubmit feature of a form. Just let the post go through as normal without the use of any javascript. Then when the popup refreshes after a successful post load this into the window. <script type="text/javascript"> //<![CDATA[ document.onload = function dropWindow() { window.opener.location.reload(true); window.close(); } //]]> </script> Not positive it will work, but it is worth a try. -- Steven |
From: Tony M. <to...@ht...> - 2005-02-10 04:04:47
|
On Wed, 9 Feb 2005, Steven Levin wrote: > On Tue, 2005-02-08 at 22:14 -0500, Tony Miller wrote: > > Thanks for the suggestion, I seem to be hitting the javascript on submit, > > the window is closing, the parent form is refreshing, but the information > > is not being submitted. Here are snippets of the generated HTML. > > > > <form id="editcigarid" name="editcigar" action="index.php" method="post"> > > <input type="hidden" name="module" value="cigardiary" /> > > <input type="hidden" name="CC_OP" value="save" /> > > > > ... > > > > <script type="text/javascript"> > > //<![CDATA[ > > > > document.getElementById('editcigarid').onsubmit=function dropWindow() { > > window.opener.location.reload(true); > > window.close(); > > return true; > > } > > > > //]]> > > </script> > > > > It should be returning true to the "onsubmit" forcing it to submit the > > data to the server. > > > > So far in my travels I've been able to either > > > > 1. Save the data and not close the popup and refresh the parent window. > > > > 2. Close the popup and refresh the parent window but not save the data. > > Try doing this instead of using the onsubmit feature of a form. Just > let the post go through as normal without the use of any javascript. > Then when the popup refreshes after a successful post load this into the > window. > > <script type="text/javascript"> > //<![CDATA[ > > document.onload = function dropWindow() { > window.opener.location.reload(true); > window.close(); > } > > //]]> > </script> > > Not positive it will work, but it is worth a try. Steven, It seems like the original works just fine in IE (it does not work in "Netscape" type browsers like Mozilla which I'm using.) I'm going to try a redirect to a url which might knock down the window. Otherwise I'll leave it up there for the netscape people to click the [x] to drop. -Tony -- Hometown Enterprises Internet Services Professional, affordable web design and hosting. http://www.hteis.com/ |