[OT] Javascript question

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
 
M

Mark Rae

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
 
R

Rob Meade

...
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 :eek:)

Regards

Rob
 
A

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;


I hope you will find it better.

Regards
Ather Ali Shaikh
 
R

Rob Meade

...
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 :eek:)

Many thanks

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top