|
 |
asptoday_discuss thread: update database from popup window
Message #1 by "Tan Chye Ting" <chyeting18@h...> on Sun, 27 Jan 2002 16:26:01
|
|
i'm trying to update database from the popup window with the
ACTION="add.asp" but i have a onClick event which all a javascript to pass
value from the popup window to the main window. so, the codings in add.asp
does not execute.how do i solve this problem?thank you
Message #2 by agaisin@c... on Sun, 27 Jan 2002 12:46:24 +0000
|
|
If I understand correctly, you have a main page and a popup.
When a user submits the form in the popup, you want to first send a value back to the main window (using javascript) and then submit
the form.
Currently you're using an onclick event to pass a value back to the main window and the page is not getting submitted...?
If that's what's going on, then I suggest instead of using onclick event, use the onsubmit event in the form element.
<form name=whatever action='add.asp' onsubmit='return processForm()'>
...
</form>
<script>
function processForm(){
/*
1) pass value back to the main window
2) then if the first step worked return true
to submit the form. If the first step didn't work
then abort the submit by returning false...
*/
}
</script>
---- Message from "Tan Chye Ting" <chyeting18@h...> at Sun, 27 Jan 2002 16:26:01 ------
i'm trying to update database from the popup window with the
ACTION="add.asp" but i have a onClick event which all a javascript to pass
value from the popup window to the main window. so, the codings in add.asp
does not execute.how do i solve this problem?thank you
Message #3 by "Tan Chye Ting" <chyeting18@h...> on Mon, 28 Jan 2002 03:58:30
|
|
you have got it right..that is what i wanna do..i have change my coding to
<form method=post action=add.asp
onsubmit=javascript:addSelectedItemsToParent() >
the javascript is to pass value from the popup window to the main window,
after i pass the value i call the window.close() function to close the
popup window
the add.asp is to add the data i input into the popup window into the
database
i have a problem here though, when i execute this i can update the
database because the window already close and i update the database using
rsPopWin("name") = Request.Form("srcName"
so i practically can't update my database unless the window is open.and i
wanna ask..does the "action" method execute first or the Onsubmit?because
if the action method is execute first, by right there shouldn't be any
problem updating the database because when add.asp is executed the window
won't be close until the javascript function is executed to close the
window... correct?can u please reply ASAP cause this part means a lot to
me..thanx
> If I understand correctly, you have a main page and a popup.
> When a user submits the form in the popup, you want to first send a
value back to the main window (using javascript) and then submit the form.
> Currently you're using an onclick event to pass a value back to the main
window and the page is not getting submitted...?
> If that's what's going on, then I suggest instead of using onclick
event, use the onsubmit event in the form element.
>
> <form name=whatever action='add.asp' onsubmit='return processForm()'>
> ...
> </form>
> <script>
> function processForm(){
> /*
> 1) pass value back to the main window
> 2) then if the first step worked return true
> to submit the form. If the first step didn't work
> then abort the submit by returning false...
> */
> }
> </script>
>
>
> ---- Message from "Tan Chye Ting" <chyeting18@h...> at Sun, 27
Jan 2002 16:26:01 ------
> i'm trying to update database from the popup window with the
> ACTION="add.asp" but i have a onClick event which all a javascript to
pass
> value from the popup window to the main window. so, the codings in
add.asp
> does not execute.how do i solve this problem?thank you
>
>
Message #4 by agaisin@c... on Mon, 28 Jan 2002 01:15:16 +0000
|
|
ok.
First, I think the correct syntax for the onsubmit attribute in the form element is
onsubmit='return addSelectedItemsToParent()'
or onsubmit='addSelectedItemsToParent()'
but not onsubmit=javascript: addSelectedItemsToParent()
that's the pseudo-url syntax you use with an href attribute
like this <a href="javascript:jscriptFunction()">click here</a>
Ok, now about your issue...
I think this is what you want to do:
1) open popup
2) get values from user in popup
3) user clicks submit
4) in addSelectedItemsToParent() function (called from onsubmit event handler) you pass values back to the parent page
5) then (if you returned true) the page values will be submitted to add.asp
6) IN ADD.ASP is where you update the db and then response.write javascript to close the window.
In other words, if everything went well in the add.asp page, then you should include this:
response.write "<script language=javascript>window.close();</script>"
and then the popup will be closed last!!
That's the trick!
good luck and hope this helped,
Arthur Gaisin
---- Message from "Tan Chye Ting" <chyeting18@h...> at Mon, 28 Jan 2002 03:58:30 ------
you have got it right..that is what i wanna do..i have change my coding to
<form method=post action=add.asp
onsubmit=javascript:addSelectedItemsToParent() >
the javascript is to pass value from the popup window to the main window,
after i pass the value i call the window.close() function to close the
popup window
the add.asp is to add the data i input into the popup window into the
database
i have a problem here though, when i execute this i can update the
database because the window already close and i update the database using
rsPopWin("name") = Request.Form("srcName"
so i practically can't update my database unless the window is open.and i
wanna ask..does the "action" method execute first or the Onsubmit?because
if the action method is execute first, by right there shouldn't be any
problem updating the database because when add.asp is executed the window
won't be close until the javascript function is executed to close the
window... correct?can u please reply ASAP cause this part means a lot to
me..thanx
> If I understand correctly, you have a main page and a popup.
> When a user submits the form in the popup, you want to first send a
value back to the main window (using javascript) and then submit the form.
> Currently you're using an onclick event to pass a value back to the main
window and the page is not getting submitted...?
> If that's what's going on, then I suggest instead of using onclick
event, use the onsubmit event in the form element.
>
> <form name=whatever action='add.asp' onsubmit='return processForm()'>
> ...
> </form>
> <script>
> function processForm(){
> /*
> 1) pass value back to the main window
> 2) then if the first step worked return true
> to submit the form. If the first step didn't work
> then abort the submit by returning false...
> */
> }
> </script>
>
>
> ---- Message from "Tan Chye Ting" <chyeting18@h...> at Sun, 27
Jan 2002 16:26:01 ------
> i'm trying to update database from the popup window with the
> ACTION="add.asp" but i have a onClick event which all a javascript to
pass
> value from the popup window to the main window. so, the codings in
add.asp
> does not execute.how do i solve this problem?thank you
>
>
Message #5 by "Tan Chye Ting" <chyeting18@h...> on Mon, 28 Jan 2002 09:48:28
|
|
hey , thank you so much i got it already...but can i ask you another
question...now, i wanna write whatever i have input into the popup window
into the main window. before that i only wanna pass it to another text box
which i did with this javascript coding..
function addSelectedItemsToParent() {
self.opener.window.document.forms[0].destName.value=window.document.forms
[0].srcName.value;
but i was thinking that if response.write can write html, why not
javascript...is there a way i can do it?what is the syntax in the first
place...
i have a vbscript to write a table dynamically like this
Response.Write _
"<TR >" & _
" <TD>" & Year & "</TH>" & _
" <TD>" & FormatNumber(Gross,3) & "</TD>" & _
" <TD>" & FormatNumber(NProMar,3) & "</TD>" & _
" <TD>" & FormatNumber(ROE,3) & "</TD>" & _
" <TD>" & FormatNumber(CurRatio,3) & "</TD>" & _
" <TD>" & FormatNumber(AcidTest,3) & "</TD>" & _
" <TD>" & FormatNumber(AnnualReGrowth,3) & "</TD>" & _
" <TD>" & FormatNumber(DebtRatio,3) & "</TD>" & _
"</TR>"
is there any way i can do it in javascript?or there are other way which u
may suggest..thanks a million
> ok.
> First, I think the correct syntax for the onsubmit attribute in the form
element is
> onsubmit='return addSelectedItemsToParent()'
> or onsubmit='addSelectedItemsToParent()'
> but not onsubmit=javascript: addSelectedItemsToParent()
> that's the pseudo-url syntax you use with an href attribute
> like this <a href="javascript:jscriptFunction()">click here</a>
>
> Ok, now about your issue...
> I think this is what you want to do:
> 1) open popup
> 2) get values from user in popup
> 3) user clicks submit
> 4) in addSelectedItemsToParent() function (called from onsubmit event
handler) you pass values back to the parent page
> 5) then (if you returned true) the page values will be submitted to
add.asp
> 6) IN ADD.ASP is where you update the db and then response.write
javascript to close the window.
> In other words, if everything went well in the add.asp page, then you
should include this:
> response.write "<script language=javascript>window.close();</script>"
> and then the popup will be closed last!!
> That's the trick!
>
> good luck and hope this helped,
> Arthur Gaisin
>
> ---- Message from "Tan Chye Ting" <chyeting18@h...> at Mon, 28
Jan 2002 03:58:30 ------
> you have got it right..that is what i wanna do..i have change my coding
to
>
> <form method=post action=add.asp
> onsubmit=javascript:addSelectedItemsToParent() >
>
> the javascript is to pass value from the popup window to the main
window,
> after i pass the value i call the window.close() function to close the
> popup window
>
> the add.asp is to add the data i input into the popup window into the
> database
>
> i have a problem here though, when i execute this i can update the
> database because the window already close and i update the database
using
>
> rsPopWin("name") = Request.Form("srcName"
>
> so i practically can't update my database unless the window is open.and
i
> wanna ask..does the "action" method execute first or the Onsubmit?
because
> if the action method is execute first, by right there shouldn't be any
> problem updating the database because when add.asp is executed the
window
> won't be close until the javascript function is executed to close the
> window... correct?can u please reply ASAP cause this part means a lot to
> me..thanx
>
> > If I understand correctly, you have a main page and a popup.
> > When a user submits the form in the popup, you want to first send a
> value back to the main window (using javascript) and then submit the
form.
> > Currently you're using an onclick event to pass a value back to the
main
> window and the page is not getting submitted...?
> > If that's what's going on, then I suggest instead of using onclick
> event, use the onsubmit event in the form element.
> >
> > <form name=whatever action='add.asp' onsubmit='return processForm()'>
> > ...
> > </form>
> > <script>
> > function processForm(){
> > /*
> > 1) pass value back to the main window
> > 2) then if the first step worked return true
> > to submit the form. If the first step didn't work
> > then abort the submit by returning false...
> > */
> > }
> > </script>
> >
> >
> > ---- Message from "Tan Chye Ting" <chyeting18@h...> at Sun, 27
> Jan 2002 16:26:01 ------
> > i'm trying to update database from the popup window with the
> > ACTION="add.asp" but i have a onClick event which all a javascript to
> pass
> > value from the popup window to the main window. so, the codings in
> add.asp
> > does not execute.how do i solve this problem?thank you
> >
> >
>
>
Message #6 by agaisin@c... on Mon, 28 Jan 2002 09:13:05 +0000
|
|
There are a number of ways you accomplish this:
1) opener.document.write('<HTML><BODY><table><tr><td>NEW TABLE
TEXT</td></tr></table></BODY></HTML>');
2) you could create elements dynamically using the DOM. This is a more sophisticated method. See this link:
http://msdn.microsoft.com/workshop/author/dom/domoverview.asp (near the bottom under "Creating Nodes") for some examples of building
a table dynamically using the dom...
var sTable="<TABLE ID='oTable1'></TABLE>"
document.body.innerHTML+=sTable;
oTable1.insertRow(oTable1.rows.length);
oTable1.rows(0).insertCell(oTable1.rows(0).cells.length);
oTable1.rows(0).cells(0).innerHTML="NEW TABLE TEXT";
or
var oTable=document.createElement("TABLE");
var oTBody=document.createElement("TBODY");
var oRow=document.createElement("TR");
var oCell=document.createElement("TD");
oRow.appendChild(oCell);
oTable.appendChild(oTBody);
oTBody.appendChild(oRow);
document.body.appendChild(oTable);
oCell.innerHTML="Cell 1";
3) similar to number 1 you could build a string of html and using the innerHtml property of one of the elements in the main document
(body or maybe some other element in there depending on how and where you want the new content to appear) you could add that html to
the main page.
like this:
body.innerHTML = '<table><tr><td>NEW TABLE TEXT</td></tr></table>'
hth,
Arthur Gaisin
---- Message from "Tan Chye Ting" <chyeting18@h...> at Mon, 28 Jan 2002 09:48:28 ------
hey , thank you so much i got it already...but can i ask you another
question...now, i wanna write whatever i have input into the popup window
into the main window. before that i only wanna pass it to another text box
which i did with this javascript coding..
function addSelectedItemsToParent() {
self.opener.window.document.forms[0].destName.value=window.document.forms
[0].srcName.value;
but i was thinking that if response.write can write html, why not
javascript...is there a way i can do it?what is the syntax in the first
place...
i have a vbscript to write a table dynamically like this
Response.Write _
"<TR >" & _
" <TD>" & Year & "</TH>" & _
" <TD>" & FormatNumber(Gross,3) & "</TD>" & _
" <TD>" & FormatNumber(NProMar,3) & "</TD>" & _
" <TD>" & FormatNumber(ROE,3) & "</TD>" & _
" <TD>" & FormatNumber(CurRatio,3) & "</TD>" & _
" <TD>" & FormatNumber(AcidTest,3) & "</TD>" & _
" <TD>" & FormatNumber(AnnualReGrowth,3) & "</TD>" & _
" <TD>" & FormatNumber(DebtRatio,3) & "</TD>" & _
"</TR>"
is there any way i can do it in javascript?or there are other way which u
may suggest..thanks a million
> ok.
> First, I think the correct syntax for the onsubmit attribute in the form
element is
> onsubmit='return addSelectedItemsToParent()'
> or onsubmit='addSelectedItemsToParent()'
> but not onsubmit=javascript: addSelectedItemsToParent()
> that's the pseudo-url syntax you use with an href attribute
> like this <a href="javascript:jscriptFunction()">click here</a>
>
> Ok, now about your issue...
> I think this is what you want to do:
> 1) open popup
> 2) get values from user in popup
> 3) user clicks submit
> 4) in addSelectedItemsToParent() function (called from onsubmit event
handler) you pass values back to the parent page
> 5) then (if you returned true) the page values will be submitted to
add.asp
> 6) IN ADD.ASP is where you update the db and then response.write
javascript to close the window.
> In other words, if everything went well in the add.asp page, then you
should include this:
> response.write "<script language=javascript>window.close();</script>"
> and then the popup will be closed last!!
> That's the trick!
>
> good luck and hope this helped,
> Arthur Gaisin
>
> ---- Message from "Tan Chye Ting" <chyeting18@h...> at Mon, 28
Jan 2002 03:58:30 ------
> you have got it right..that is what i wanna do..i have change my coding
to
>
> <form method=post action=add.asp
> onsubmit=javascript:addSelectedItemsToParent() >
>
> the javascript is to pass value from the popup window to the main
window,
> after i pass the value i call the window.close() function to close the
> popup window
>
> the add.asp is to add the data i input into the popup window into the
> database
>
> i have a problem here though, when i execute this i can update the
> database because the window already close and i update the database
using
>
> rsPopWin("name") = Request.Form("srcName"
>
> so i practically can't update my database unless the window is open.and
i
> wanna ask..does the "action" method execute first or the Onsubmit?
because
> if the action method is execute first, by right there shouldn't be any
> problem updating the database because when add.asp is executed the
window
> won't be close until the javascript function is executed to close the
> window... correct?can u please reply ASAP cause this part means a lot to
> me..thanx
>
> > If I understand correctly, you have a main page and a popup.
> > When a user submits the form in the popup, you want to first send a
> value back to the main window (using javascript) and then submit the
form.
> > Currently you're using an onclick event to pass a value back to the
main
> window and the page is not getting submitted...?
> > If that's what's going on, then I suggest instead of using onclick
> event, use the onsubmit event in the form element.
> >
> > <form name=whatever action='add.asp' onsubmit='return processForm()'>
> > ...
> > </form>
> > <script>
> > function processForm(){
> > /*
> > 1) pass value back to the main window
> > 2) then if the first step worked return true
> > to submit the form. If the first step didn't work
> > then abort the submit by returning false...
> > */
> > }
> > </script>
> >
> >
> > ---- Message from "Tan Chye Ting" <chyeting18@h...> at Sun, 27
> Jan 2002 16:26:01 ------
> > i'm trying to update database from the popup window with the
> > ACTION="add.asp" but i have a onClick event which all a javascript to
> pass
> > value from the popup window to the main window. so, the codings in
> add.asp
> > does not execute.how do i solve this problem?thank you
> >
> >
>
>
Message #7 by "Tan Chye Ting" <chyeting18@h...> on Mon, 28 Jan 2002 17:16:33
|
|
ok, i think i got another question...u know what i wanna do rite..actually
i wanna update my data in the main window once i enter my data into the
popup window...i was thinking maybe i can do it if i can refresh the main
window before i close the popup window..because by then i would have
updated my database..can i do it? how does the syntac goes?
|
|
 |