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