codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  inserting values from pop up  Archive Import (diego) at 02:30 on Wednesday, August 27, 2003
 

good day!

i want to ak, in first.asp, displays the checkbox and the value is the ID of the table LOAForms. In this page it will display all the info of all employee.

my codes is this

set rs = server.createobject("ADODB.Recordset")
sql="Select * from LOAForms where status=`pending` "
rs.Open sql, conn,3,3

<form action="/forum/2nd.html" method="post" >
if not rs.eof then
do
<input type="checkbox" name="delitem3" value="<%=rs("id")%>">
rs.movenext
loop until rs.eof
end if
</form
<input type="submit" name="btntype" value="Disapprove Leave" >


codes in 2nd.asp.
In this page, it will update all checked boxes

intdelitem = trim(request("delitem"))
if intdelitem <> "" then
disapp = "disapproved"
Set rsapproveLOA = Server.CreateObject("ADODB.Recordset")
sqlXDel1 = "Update LOAForms Set status1=`"& cancelled &" `, statusDte=`"& recentdate &"` where ReferenceNO IN (" & intdelitem &")"

rsapproveLOA.Open sqlXDel1, conn
end if

if i click the submit button it will display a pop up with a textarea and i will input the reason why i disapprove and click the button and close the pop up.

the values from textarea will update the table LOAForms

How is that?

Pls help..

thanks,
arazia

  Re: inserting values from pop up  Troy Wolf at 14:03 on Wednesday, August 27, 2003
 

If I understand correct, you have a page with a form. This page pops up a window. You want the popup window to update the form on the parent window?

In Javascript in the popup window:
self.opener.forms[0].someElementName.value = document.forms[0].myTextArea.value;

By prefixing your object with "self.opener." you reference objects on the parent window instead of the current window.

After your action to update the parent form, perhaps you want to auto close the popup. You can add this line to the end of your javascript function:
self.close();
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: inserting values from pop up  Archive Import (diego) at 20:30 on Wednesday, August 27, 2003
 

can you give me the complete script for that? because i dont know where to start..

thanks,
diego

  Re: inserting values from pop up - complete script  Troy Wolf at 00:22 on Thursday, August 28, 2003
 

Complete script? You asked for it--here it is.

First file. Name this "test.html".
-------------------------------------------
<html>
<head>
<title>Example code from Troy Wolf</title>
<script language=javascript>
function GetReason() {
var winWidth = 300;
var winHeight = 300;
var winLeft = (screen.width-winWidth)/2;
var winTop = (screen.height-winHeight)/2;
win1 = window.open("reason.html", "Reason", +
"menubar=0,toolbar=0,resizable=1,scrollbars=0" +
",width=" + winWidth + ",height=" + winHeight +
",top="+winTop+",left="+winLeft);
}
function SetReason(reasonText) {
document.forms[0].value = reasonText;
document.forms[0].submit();
}
</script>
</head>
<body>
When you click the button, a small popup window will be centered in your screen.
When you submit the popup window, the value from the textarea will be passed into
a hidden element on this page. Then this page will automatically submit.
<p>
<form onsubmit="return false" action="/forum/2nd.html" method="post">
<input type=hidden name=reasonText>
<input type=button name="btntype" value="Disapprove Leave" onclick="GetReason()">
</form>
</body>
</html>
-------------------------------------------

Here is the code for the popup window. Name this file "reason.html".
-------------------------------------------
<html>
<head>
<title>Example code from Troy Wolf</title>
<script language=javascript>
function SubmitReason() {
self.opener.SetReason(document.forms[0].reasonText.value);
self.close();
}
</script>
</head>
<body onload=self.focus()>
<form>
<textarea name=reasonText cols=30 rows=10>Enter your reason for denial here.</textarea>
<br><input type=button value="Submit" onclick="SubmitReason()">
</form>
</body>
</html>
-------------------------------------------

Save these two files in the same folder, then run test.html. This is tested and working code to accomplish your goal. You of course need to add in your content, but the scripting for the popup and the auto-submission are in place.
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: inserting values from pop up  Troy Wolf at 00:23 on Thursday, August 28, 2003
 

Ooops. I said tested and working...but I`m so silly. I was just kidding. Change this line:

document.forms[0].value = reasonText;

To this:

document.forms[0].reasonText.value = reasonText;

If you notice any other problems or need further help, reply back here.
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: inserting values from pop up  vijay13c at 10:45 on Sunday, December 02, 2007
 

Hi, i was just looking for this code, i need to do few changes, instead of a passing a single value from a textarea, how do i pass multiple selected values from a list box, to the parent window text field. any idea, i changed the textarea into a listbox, but only one selection is passed into the parent field, i wanted to pass multiple values which is seperated by a comma value. is it possible? i need a quick response..








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: partial string sorting of arrays
•  Passing Multiple Values from a child window to parent window
•  Re: inserting values from pop up
•  jumping to a different web page
•  Re: Page Load is getting called twice
•  values from asp to html
•  Re: Write text strings to Serial Port
•  Calcluate Date Difference [Seriouslt a new challenge]
•  source code to generate perl library


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007