By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

Set Text in form field from pop up window

P: n/a

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!

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a

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
Jul 23 '05 #2

P: n/a

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

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

Thanks again for your help.

*** Sent via Developersdex ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3

P: n/a

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 ='','NewWin',
'toolbar=no,status=no,scrollbars=1,resizable=1,wid th=630,height=700,left=100,top=100')

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!

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.