M
momonga
Hi
I'm really new to ASP.NET and would be very grateful any advice.
I want to search a database and put the each results into the value of
hidden field to refer them from javascript.
but I don't know how to it at all..
I'm thinking about the following approach.
(1) Search the database at Page_Load().
(2) Put the following html to the page somehow.
"<input type="hidden" id="totalrows" value=10>"
"<input type="hidden" id="row0" value="the result 0">"
"<input type="hidden" id="row1" value="the result 1">"
..
..
..
(3) Use the values from javascript as following.
function func()
{
totalRows = document.getElementById("totalrows").value;
for(i = 0 ; i < totalRows ; i++)
{
var str_id = "row" + i;
var x = document.getElementById(str_id);
alert(x.value);
}
}
My question is...
(a) Is my way good in the ASP.NET custom?
(b) How to put some hidden input tags to the page?(step(2))
I'm really new to ASP.NET and would be very grateful any advice.
I want to search a database and put the each results into the value of
hidden field to refer them from javascript.
but I don't know how to it at all..
I'm thinking about the following approach.
(1) Search the database at Page_Load().
(2) Put the following html to the page somehow.
"<input type="hidden" id="totalrows" value=10>"
"<input type="hidden" id="row0" value="the result 0">"
"<input type="hidden" id="row1" value="the result 1">"
..
..
..
(3) Use the values from javascript as following.
function func()
{
totalRows = document.getElementById("totalrows").value;
for(i = 0 ; i < totalRows ; i++)
{
var str_id = "row" + i;
var x = document.getElementById(str_id);
alert(x.value);
}
}
My question is...
(a) Is my way good in the ASP.NET custom?
(b) How to put some hidden input tags to the page?(step(2))