Improve company productivity with a Business Account.Sign Up

x
?
Solved

JavaScript write the data from pop-up form back to main.asp

Posted on 2004-08-20
13
Medium Priority
?
418 Views
Last Modified: 2008-02-01
Hi Experts,

Below is what I am trying to accomplish:

I have main.asp and pup.asp. There is an Textbox "Email" and a "Add email" link next to the Textbox on main.asp. If the user click "Add email" link, it will pup-up pup.asp which ask user to check-mark from an email list. once it is done, the user click on 'Submit button' on pup.asp and the value will be write back to the Textbox "Email" in main.asp.

The following is the code for check-box in pup.asp:
"  <TD><INPUT TYPE='checkbox' name=""chk_"&rsItems1("EmailAddr")& """ value= "&rsItems1("EmailAddr")&">" & _
       
                "</TR>"

once the user click on submit button on pup.asp, it will go to "AddEmail.asp", below is the code for "AddEmail.asp":
<script language=javascript>

self.opener.frmUser.noticeemail.value='<%=chk_%>'
self.close()
</script>

frmUser is the form name for main.asp. noticeemail is the name of the Textbox in main.asp.


It won't write anything to Textbox now.

Thanks in advance!
0
Comment
Question by:mrong
  • 5
  • 4
  • 2
11 Comments
 
LVL 2

Expert Comment

by:rabanero
ID: 11850973
You have to replace noticeemail object into frmUser form, with:

<input type="hidden" name="noticeemail" />

Nothing appears in the screen, but value returned by pup.asp will be saved and sent in frmUser submit.
0
 
LVL 3

Expert Comment

by:mattfairw
ID: 11850983
window.opener.document.frmUser.DateFieldName.value = TheDateSelectedOnThePopUp
0
 

Author Comment

by:mrong
ID: 11850992
My bad, the Textbox is "noticeemail" on the main.asp
I want the Textbox "noticeemail" display on the main.asp

Thanks.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:mrong
ID: 11851003
mattfairw,

Could you pls use the name which I used in the code?
Thanks.
0
 
LVL 2

Expert Comment

by:rabanero
ID: 11851016
I don't understand. Sorry :(
0
 

Author Comment

by:mrong
ID: 11851033
Can I write the data back to Textbox "noticeemail"(main.asp) from pup.asp?

I have Textbox "noticeemail" on the main.asp already.

Thanks.
0
 
LVL 3

Expert Comment

by:mattfairw
ID: 11851213
in the popup, after the user has selected the date you wish, you would call the form element by name just like you would if you were on the main page, but tack on "window.opener" at the beginning. So:

window.opener.document.frmUser.noticeemail.value = TheDateSelectedOnThePopUp

-Matt
0
 

Author Comment

by:mrong
ID: 11851242
SHouldn't it be self.opener.frmUser.noticeemail.value='<%=chk_%>'?
I changed to self.opener.document.frmUser.noticeemail.value=chk, but the form didn't submit.
0
 
LVL 3

Accepted Solution

by:
mattfairw earned 400 total points
ID: 11851335
well if each checkbox has a value, you would assign to the main form the value that was clicked. You would only use the ASP if you were going to reload the main page by passing it a query string, have the popup have an onSubmit function that will check the popup form for the email checked, and send that back to the main page like:

var numCntrls = document.popUpFormName.length;
var cntrlIndex, element;

for (cntrlIndex = 0; cntrlIndex < numCntrls; cntrlIndex++)
{
  element = document.popUpFormName[cntrlIndex];
  if (element.type == "checkbox")
    if (element.checked)
    {
      window.opener.frmUser.noticeemail.value = element.value;
      window.close();
    }
}

-Matt
0
 

Author Comment

by:mrong
ID: 11851989
I don't want to reload the main.asp coz the user might have already edit some data in main.asp and I don't want them to lose it. Is it possible to do?
0
 
LVL 3

Expert Comment

by:mattfairw
ID: 11853953
the code i gave you does not reload the main page. it is all javascript
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

595 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question