Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / August 2004

Tip: Looking for answers? Try searching our database.

Populating parent form question...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rob Meade - 09 Aug 2004 14:29 GMT
Hi all,

I  have datagrid on a popup window which for each row spat out has a
"Select" option - its a hyperlink - when clicked it runs the calls a
javascript function - this function should populate the parent form, my
problem is that I need to update the fields dynamically - ie, I wont know
what the field name actually is...

The code I have thus far:

Calling the function:
<a class="normalText" href="javascript:void(0);"
onclick="populateForm('<%=Request.QueryString("controlid") %>', '<%#
DataBinder.Eval(Container.DataItem, "CrfExpansion") %> ','<%#
DataBinder.Eval(Container.DataItem, "CrfDHANationalCode") %>');">Select</a>

The function:

function populateForm(controlID, displayValue, hiddenValue)
   {
       opener.document.form1.controlid.value = displayValue;
   }

The reason that there are more values coming into the function is because
there are some further plans with this, it will infact update 2 fields on
the parent form - but I wanted to get one working first!

As you can see I have controlID in this line:

opener.document.form1.controlid.value = displayValue

but I believe its actually using that as text, rather than the value it
holds and thus returns an error about the object being null etc..

Any help would be appreciated,

Regards

Rob
bruce barker - 09 Aug 2004 17:13 GMT
try:

   opener.document.form1[controlid].value = displayValue; // controlid must
evaluate to the name of the control

or

   opener.document.getElementById(controlid).value = displayValue; //
controlid must evaluate to the if of the control

-- bruce (sqlwork.com)

> Hi all,
>
[quoted text clipped - 35 lines]
>
> Rob
Rob Meade - 10 Aug 2004 09:56 GMT
"bruce barker" wrote...

> try:
>
[quoted text clipped - 5 lines]
>     opener.document.getElementById(controlid).value = displayValue; //
> controlid must evaluate to the if of the control

Hi Bruce,

Someone in the asp.net group was kind enough to post a reply (after this
group was suggested to me) - which seems to work - many thanks for your
reply.

// populate the display control
var displayControl = eval("opener.document.Form1."+displayControlID);
displayControl.value = displayValue;

Thanks again,

Regards

Rob

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.