Get Datalist Row number (index) thru javascript
Get Datalist Row number (index) thru javascript
am 05.01.2008 23:35:57 von MD Websunlimited
Condition:
A Timesheet entry page with 2 weeks displayed in a Datalist control.
What I need to do is associate a single Memo textbox back to the clicked,
Time entered Textbox with javascript.
I have 16 textboxes per row, with a bound hiddenfield for each of those for
the memo to be stored in for that day's column field, per project row. What
I do not know how to do is on the "onblur" event of the Memo textbox write
back to the hiddenfield what is written into the Memo.
Because there are many rows, and each row has a unique ClientID, I'm not
sure how to get the row number from javascript, as it not a selected row,
just a clicked Textbox on the Time entered textbox of a row.
I can pass it the original TextBox clicked day ID, but how do I get or pass
it the row number. I've tried using the ClientID Method as below but the
build fails.
I basically need to get the Datalist Row number or pass it thru to the
function from just a TextBox Click without a PostBack, just JavaScript.
The hiddenfields Id's are Hm1 thru Hm16
Thanks
John
Re: Get Datalist Row number (index) thru javascript
am 06.01.2008 01:55:32 von Toze
hi john try this
onitemdatabond of the datalist
Dim counter As Integer = 1
While counter < 17
Dim tbox As TextBox = e.Item.FindControl("TextBox" & counter)
Dim hidden As HiddenField = e.Item.FindControl("HiddenField" & counter)
tbox.Attributes.Add("onblur", "item_onBlur('" & tbox.ClientID & "', '" &
hidden.ClientID & "', " & e.Item.ItemIndex & ");")
counter += 1
End While
javascript:
function item_onBlur(tboxId, hiddenId, rowIndex)
{
var tbox = document.getElementById(tboxId);
var hidden = document.getElementById(hiddenId);
}
hope it helps
"john" wrote in message
news:uyhEZt%23TIHA.5264@TK2MSFTNGP02.phx.gbl...
> Condition:
>
> A Timesheet entry page with 2 weeks displayed in a Datalist control.
>
>
>
> What I need to do is associate a single Memo textbox back to the clicked,
> Time entered Textbox with javascript.
>
>
>
> I have 16 textboxes per row, with a bound hiddenfield for each of those
> for the memo to be stored in for that day's column field, per project row.
> What I do not know how to do is on the "onblur" event of the Memo textbox
> write back to the hiddenfield what is written into the Memo.
>
>
>
> Because there are many rows, and each row has a unique ClientID, I'm not
> sure how to get the row number from javascript, as it not a selected row,
> just a clicked Textbox on the Time entered textbox of a row.
>
>
>
> I can pass it the original TextBox clicked day ID, but how do I get or
> pass it the row number. I've tried using the ClientID Method as below but
> the build fails.
>
>
>
> I basically need to get the Datalist Row number or pass it thru to the
> function from just a TextBox Click without a PostBack, just JavaScript.
>
>
>
> The hiddenfields Id's are Hm1 thru Hm16
>
>
>
>
>
>
>
> Thanks
>
> John
>
>
Re: Get Datalist Row number (index) thru javascript
am 06.01.2008 03:55:04 von MD Websunlimited
Thanks, that is what I needed
John
"Toze" wrote in message
news:O$JPc7$TIHA.748@TK2MSFTNGP04.phx.gbl...
> hi john try this
>
> onitemdatabond of the datalist
> Dim counter As Integer = 1
> While counter < 17
>
> Dim tbox As TextBox = e.Item.FindControl("TextBox" & counter)
>
> Dim hidden As HiddenField = e.Item.FindControl("HiddenField" & counter)
>
> tbox.Attributes.Add("onblur", "item_onBlur('" & tbox.ClientID & "', '" &
> hidden.ClientID & "', " & e.Item.ItemIndex & ");")
>
> counter += 1
>
> End While
>
>
>
>
>
>
>
> javascript:
>
> function item_onBlur(tboxId, hiddenId, rowIndex)
>
> {
>
> var tbox = document.getElementById(tboxId);
>
> var hidden = document.getElementById(hiddenId);
>
>
>
> }
>
> hope it helps
>
>
> "john" wrote in message
> news:uyhEZt%23TIHA.5264@TK2MSFTNGP02.phx.gbl...
>> Condition:
>>
>> A Timesheet entry page with 2 weeks displayed in a Datalist control.
>>
>>
>>
>> What I need to do is associate a single Memo textbox back to the clicked,
>> Time entered Textbox with javascript.
>>
>>
>>
>> I have 16 textboxes per row, with a bound hiddenfield for each of those
>> for the memo to be stored in for that day's column field, per project
>> row. What I do not know how to do is on the "onblur" event of the Memo
>> textbox write back to the hiddenfield what is written into the Memo.
>>
>>
>>
>> Because there are many rows, and each row has a unique ClientID, I'm not
>> sure how to get the row number from javascript, as it not a selected row,
>> just a clicked Textbox on the Time entered textbox of a row.
>>
>>
>>
>> I can pass it the original TextBox clicked day ID, but how do I get or
>> pass it the row number. I've tried using the ClientID Method as below but
>> the build fails.
>>
>>
>>
>> I basically need to get the Datalist Row number or pass it thru to the
>> function from just a TextBox Click without a PostBack, just JavaScript.
>>
>>
>>
>> The hiddenfields Id's are Hm1 thru Hm16
>>
>>
>>
>>
>>
>>
>>
>> Thanks
>>
>> John
>>
>>
>
>