473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Popup value returned to parent window

384 256MB
I have a page that has this code that opens a popup winodw, I need the value thats clicked on to be added to the span on the parent page, can anyone help? Also if you click something from the popup window and something already exists in the span it will append the new value to the exist value in the span?

I greatly appreciate any help here, thanks.

Parent page:
Expand|Select|Wrap|Line Numbers
  1. <a href="#" onClick="targetitem = document.forms[0].related;dataitem = window.open('popup2.php','dataitem','width=200, height=100, top=10, left=300');dataitem.targetitem = targetitem">add</a> <label name="related"></label>
Popup page:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>Javascript(Popup 2)</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
  6. <script>
  7. function select_item(item) {
  8.     targetitem.value = item;
  9.     top.close();
  10.     return false;
  11. }
  12. </script>
  13. </head>
  14. <body>
  15. <label onClick='return select_item("1");'>test 1</label>
  16. </body>
  17. </html>
May 26 '11 #1

✓ answered by ziycon

Got it, i needed to use getElementById instead of getElementsByName.

2 4961
ziycon
384 256MB
I've gotten to the stage where I'm not getting any JS errors but I can't get the popup box value to append to the label on the parent page, can anyone point me in the right direction please?

Parent:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>Javascript(Popup)</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
  6. </head>
  7. <body>
  8. <form>
  9. <a href="#" onClick="targetitem = document.getElementsByName('related');dataitem = window.open('popup2.php','dataitem','width=200, height=100, top=10, left=300');dataitem.targetitem = targetitem">add</a>
  10. <label name="related"></label>
  11. </form>
  12.  
  13. </body>
  14. </html>
Popup:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>Javascript(Popup 2)</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
  6. <script>
  7. function select_item(item) {
  8.     targetitem.innerHTML = item;
  9.     top.close();
  10.     return false;
  11. }
  12. </script>
  13.  
  14. </head>
  15. <body>
  16. <label onClick='return select_item("1");'>test 1</label><br/>
  17. <label onClick='return select_item("2");'>test 2</label>
  18. </body>
  19. </html>
May 27 '11 #2
ziycon
384 256MB
Got it, i needed to use getElementById instead of getElementsByName.
May 27 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: umashd | last post by:
Hi, I am doing a web based project for my graduation. I studied bit of java for backend processesing and javascript for the client. Here is the scenario. In the FORM, I use INPUT TYPE=text...
4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
5
by: midnight_use_only | last post by:
hi all, quick question, how do you submit a form to a parent window from a child popup window? i have the following and all online documentation *suggests* that it should work but it does NOT: ...
1
by: Socrates | last post by:
Hi - Have tried for half and hour to get this script to work: I am trying to close the parent window while opening a centred new child window I would be grateful if someone could correct the...
2
by: rishhi04 | last post by:
how to pass jsp child window value to parent jsp window .particular field or focus field
4
by: Adam | last post by:
hi, i'm new to JS, wondering how one would go about creating a popup window that would exactly copy the size & location of the parent window. i am guessing that you would combine two functions,...
5
by: BibhuAshish | last post by:
Hello, I have one child window. in child window i am selecting one radio button. i want to return that selected value to parent window. To open child window in parent window, i have written like...
10
by: perhapscwk | last post by:
how to passing value from popup to the parent window as a variable which I can access and process the variable(string) in parent window? such as from popup page, we have var_from_popup="abc",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.