TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sudharsan s
NA
204
86.9k
how can i pass grid values to textbox using javascript?
Apr 25 2012 1:57 AM
This is the code i am using bind the database values and display the values in html table.
public void load_builder()
{
SqlConnection con = new SqlConnection(constring);
con.Open();
string sql = "select category,category_code,created_date from category";
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
//sb.Append("<tbody>");
while (dr.Read())
{
sb.Append("<tr >");
sb.Append("<td><label
onclick='loaddata
(" + dr[0].ToString() + ")'>
select<
/label></td>");
sb.Append("<td id='c1" + dr[0].ToString() +"'>" + dr[0].ToString() + "</td>");
sb.Append("<td id='c2" + dr[0].ToString() + "'>" + dr[1].ToString() + "</td>");
sb.Append("</tr>");
}
this is the html table grid structure.
<table cellpadding="0" align="left" cellspacing="0" border="0" id="table" class="tinytable">
<thead>
<tr>
<th><h3>
select
</h3></th>
<th><h3>Category Name</h3></th>
<th><h3>Category Code</h3></th>
</tr>
</thead>
<tbody>
after clicking this
select
option i want display the particular row values into particular text fields for update purpose..that means (cateory name and categorycode )data want to display in text fields.
for this purpose i am using the javascript function called loaddata
loaddata code:
<script type="text/javascript">
function loaddata(val) {
document.getElementById("<%=txtxtCategoryCode.ClientID%>").value = document.getElementById("c2" + val + "").innerHTML;
document.getElementById("<%=txtcategory.ClientID%>").value = document.getElementById("c1" + val + "").innerHTML;
}
</script>
but i am not able to get the particular row values to text box after clicking the select option..
Help me for this......
Advanec thx..
Reply
Answers (
7
)
Insert data in mysql with codeigniter in PHP
Display multiple image in a table in PHP