?
Solved

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

Posted on 2004-08-20
13
Medium Priority
?
409 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
13 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

762 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