[OT] Javascript question

  • Thread starter Thread starter Rob Meade
  • Start date Start date
R

Rob Meade

Hi all,

firstly, sorry if this is deemed off topic - at work we only have access to
the MS newsgroups and I dont see a Javascript one listed :(

Ok - so the question.

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
 
firstly, sorry if this is deemed off topic - at work we only have access to
the MS newsgroups and I dont see a Javascript one listed :(

microsoft.public.dotnet.languages.jscript
 
...
microsoft.public.dotnet.languages.jscript

Hi Mark,

Many thanks for the group - I've managed to find it now - think it missed it
before as I was looking for 'javascript' not 'jscript' - many thanks :o)

Regards

Rob
 
if you want to evaluate your controlid you can use like this.

var myControl = eval("opener.document.form1."+controlid);
myControl.value = displayValue;


I hope you will find it better.

Regards
Ather Ali Shaikh
 
...
if you want to evaluate your controlid you can use like this.

var myControl = eval("opener.document.form1."+controlid);
myControl.value = displayValue;

Hello Ather,

Many thanks for the reply and information - I have just tried that - whilst
it didn't work immediately it feels like I'm closer :o)

Many thanks

Rob
 
Back
Top