473,788 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5912


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.eleme nts.elementName .value = ...;
}

--

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,sta tus=no,scrollba rs=1,resizable= 1,width=630,hei ght=700,left=10 0,top=100')
aff.location="T ownPicker.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.Fie lds.Item("TownI D").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_setTextOfTex tfield function and
add this line to the end of the function:
opener.document .form1.elements .SCoTownID.valu e = 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_setTextOfTex tfield(objName, x,newText) { //v3.0
var obj = MM_findObj(objN ame); if (obj) obj.value = newText;
opener.document .form1.elements .SCoTownID.valu e = 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
3236
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 generated, though. I'd like to capture the NAME of every HTML form field element on the server, even if that element is submitted blank. The trouble is, with, say, radio buttons or checkboxes for example, a *blank* element does not get submitted at all.
2
2197
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 tried storing the handle of Window A ( var winHandle = this; ) in a global variable/file ( globals.js ) and then accessing it from
3
2910
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 page, and code to close the window. ------------------------------------------ the help window code is following <SCRIPT LANGUAGE="JavaScript"> <!-- Begin
6
2834
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 some one tell me what I'm doing wrong? it looks like this: var tbl=document.tbl; var frm=document.frm; var newcell=document.createElement("TD");
1
2037
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
5957
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) I think that some how I need to pass the generated string as the action but can't figure how to do it. Can someone please tell me where I am going wrong and maybe suggest a solution.
4
3906
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 inserted in the database, to enable me then to reference that number at a later date. (The hidden value (1 for example) would then automatically get passed to the other input field.)
5
3017
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 field 1 to field 3, then field 2 text and field 3 move to field 1 and field 2. I add the new order of text into an array so when the onDragEnd event
9
1961
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 requested by the user, the hidden main form field take value = 0; 2) If the window is open to force the user to make a choice within the select. Can you help me?
2
7243
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
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.