Click to See Complete Forum and Search --> : Get ID from input


kahlua001
12-02-2003, 11:05 AM
This is probably easy, when I have something like:

<input type="text" id="dynamically_generated_name" onFocus="display_id();">


How do I pass display_id() the ID of the base input field? I would dynamically generate the name in the inline code but I have no control of what name is going to be generated. Thanks.

AdamGundry
12-02-2003, 11:51 AM
Try this:

<input type="text" id="dynamically_generated_name" onFocus="display_id(this.id);">

Adam

kahlua001
12-02-2003, 04:03 PM
Thanks, I figured that part out :) But I still get an error. The Textbox is being generated by a datagrid control in ASP.NET. So..the name of the textbox looks like "dgrdNotices:_ctl2:txtNote" Now when I attempt to grab the name it chokes up, say

function display_id (formname) {

eval("document.MyForm." + formname + ".value") = '';

}

I get a syntax error 'Cannot assign to a function result' Anyway around that? Thanks