473,394 Members | 1,679 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,394 software developers and data experts.

Set Text in form field from pop up window

Hi

I'm not much of a javascripter, so I don't know whether this is
possible, but......

I have a pop-up window in my asp web app which lets the user select a
record from table1 from an alphabetical list - you know, the A | B | C
| D filter thang.

At the moment they have to cut and paste the appropriate recordID into
a text box on the parent form, which is editing data from table2 (ie.
this process is linking the two tables).

I know I can use javascript to set the text in a box on a form if I
check a box elsewhere on the same form. Question is, can I set the
text in the parent form when I check a box on the pop-up?

Any pointers very gratefully received!

Thanks
Jul 23 '05 #1
3 5868


Tim Pollard wrote:

I know I can use javascript to set the text in a box on a form if I
check a box elsewhere on the same form. Question is, can I set the
text in the parent form when I check a box on the pop-up?


You can access the opening window as follows
if (opener && !opener.closed) {
opener.document.formName.elements.elementName.valu e = ...;
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2


Hi Martin

Thanks for the prompt reply. I hope you don't mind me posting a follow
up question.

I think I get this! I don't need to have assigned any particular name to
the opening window, provided I have opened the popup using javascript?

To complicate matters my checkbox (or perhaps better a radiobutton) to
pick the appropriate value to carry across will be in an asp repeat
region where the rb (or checkbox) name is static but the value is
dynamic. Can I assign a value using vbscript in the middle of the
javascript? And how do I apply the code to the rb - make it an onClick
event?

Sorry for the silly questions - like I said, I'm not much of a
javascripter!

Thanks again for your help.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
Hi

For the benefit of anyone following this thread later, here's how I
solved it by using the help above and applying it to the way
Dreamweaver does things:

Step 1

Called the popup from a # link on the master page, onClick the link
calls function openwin() .

Function openwin looks like this in code view:

function openwin() {
aff = window.open('','NewWin',
'toolbar=no,status=no,scrollbars=1,resizable=1,wid th=630,height=700,left=100,top=100')
aff.location="TownPicker.asp";
}

Townpicker.asp is my pop up page.

Step 2

Made sure my pop up repeat region was inside a form tag.

Put a radiobutton in my repeat region and assigned the dynamic ID to
it as its value.

Created a text field and applied the Set Text behaviour onClick to the
radiobutton, setting the dynamic ID as the value to write to the text
box. e.g. set it to write <%=(rsTowns.Fields.Item("TownID").Value)%>

Check this is all working when the radiobuttons are clicked - check
the text changes from button to button.

Step 3

Find the script for the macromedia MM_setTextOfTextfield function and
add this line to the end of the function:
opener.document.form1.elements.SCoTownID.value = newText;
where form1 is the name of the form on the parent page and SCoTownID
is the name of the field on it you want to populate.

Thus the modified code for the set text function is:

function MM_setTextOfTextfield(objName,x,newText) { //v3.0
var obj = MM_findObj(objName); if (obj) obj.value = newText;
opener.document.form1.elements.SCoTownID.value = newText;
}

What this does is take the value the MM function has generated
(newText) and pushed it back to the field in the opening page.

Once this is all working properly you can hide the text field in the
popup and it should now all work fine.

Many thanks for the suggestion that solved this problem for me!

TP
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: JDS | last post by:
Hi, all. I'd like to do the following, preferably *without* resorting to JavaScript: I have a long, dynamically-generated form questionnaire. Not all of the form fields are dynamically...
2
by: Juan Garcia | last post by:
Subject says it all. Given: Window A with text field. Window B with a button (onClick opens Window C) Window C with a button (onClick I want it to modify text fields of Window A) I have...
3
by: Treetop | last post by:
I would like to pass text to a popup window to save creating a new html file for each help topic. I would like to have a value for the heading, a value for the text, code for printing the help...
6
by: Amir Hardon | last post by:
I'm new to DOM and can't figure out this thing: I'm trying to add a row to a table with a form field in one of it's cells, but if I'm appending the field to a form it gets out of the table. Can...
1
by: reneecccwest | last post by:
hello, is there any way to indicte a cursor on the first text user input when a page loads without using onload in the body tag?
3
by: Steve Wright | last post by:
I want to build an email subject containing text and a form field. Have have got so far but all I seem to be able to do is generate another page in the browser with a text string. (code attached)...
4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
5
by: simon_s_li | last post by:
Hi, I have 5 fields in line where I need to drag and drop the text from one field to another field and then all the fields need to re-order themselves. So for instance if I drag the text in...
9
by: viki1967 | last post by:
Hi all. I have this JavaScript function that copy the value ( selected in a select open in a window popup), in the hidden main form field. I need this changes: 1) If the popup window is not...
2
by: jerald m | last post by:
Hi, how can i pass the user input value of ( in text box field) to the another Jsp in url? Form Code <td> <input type="text" name="dil_ProjectCode" id="dil_ProjectCode"> </td>
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.