Javascript hyperlink ID in a Datalist = Undefined

M

milbrand

I have an ASPX page with a DataList. The ListItems contain a
DropDownList and a Hyper Link. The user selects an Item from the
Dropdown box and then selects the hyperlink to edit that item.

My thought was to grab the ID, ClientID, or UniqueID of the Hyperlink
and then build the name of the DropDownList to grab the value to pass.
The problem is that the value keeps coming back Undefined. How can I
get the dynamic name created at runtime?

My Code:

**javascript**
function floorplanpopup(i)
{
var j = i.ClientId.length - 33;
var no = i.ClientId.substring(20, j);
var x =
document.getElementById("dl_notification:_ctl"+no+":dd_floorplan");
day = new Date();
id = day.getTime();
eval("page"+id + " =
window.open('FloorPlanSetup.aspx?did="+x.value+"', '" + id + "',
'width=350, height=500');");
}

**Datalist Code**
<asp:label class="lblnormal" id="lbl_floorplan" runat="server"
Font-Size="X-Small">Floor Plan Name:</asp:label>

<asp:dropdownlist class="normal" id="dd_floorplan" runat="server"
DataTextField="FLOORPLAN_NAME"
DataValueField="FLOORPLAN_ID"></asp:dropdownlist>

<asp:HyperLink id="hl_floorplan" runat="server"
NavigateUrl="javascript:floorplanpopup(this);"
ImageUrl="images/AddButton.gif"></asp:HyperLink>


Anyhelp is greatly appreciated.

~Brad
 
B

bruce barker \(sqlwork.com\)

you want the uniqueid or calc dropdown id from passed.

function floorplanpopup(i)
{
var x =
document.getElementById(i.id.replace(/hl_floorplan/i,'dl_floorplan'));
.....

-- bruce (sqlwork.com)
 
M

milbrand

That really helps out in the changing of the name, but I still have the
issue that the i.id is undefined.

If I use the code you suggest, it comes back with an error: 'id' is
null or not an object.

Is it possible to pull the ID from a hyperlink?
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top