smrb59
شنبه 25 مهر 1388, 21:58 عصر
با سلام .من دیتالیست رو پر می کنم حالا میخوام توسط یک دکمه به عناصر موجود در اون دسترسی داشته باشم البته از طریق جاوا اسکریپت.من کد رو گذاشتم .هر چه سعی کردم نتونستم .لطفا کمکم کنید.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function show()
{
var p=document.getElementById('p1');
alert(p.value);
var p1=document.getElementById('lproducts');
alert(p1.innertext);
}
function show1()
{
var p1=document.getElementById('p1');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList RepeatColumns="2" GridLines="Both" DataKeyField="Pk_id" Width="100%"
runat="server" ID="ListProducts"
>
<ItemTemplate>
<table dir="rtl" >
<tr>
<td>
<input id="p1" runat="server" onclick="return show()" type="button" value='<%#bind("Product") %>' />
<asp:Label ID="lproducts" Text="<%#bind('Product') %>" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td>
<img id="imgproduct" height="50" width="40" runat="server" src="<%#bind('Url') %>" alt="<%#bind('Product') %>" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="ltozihat" Text="<%#bind('Tozihat') %>" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td>
قیمت : <asp:Label ID="lbl" Text="<%#bind('Price') %>" runat="server" ></asp:Label>
<br />
</td>
</tr>
<tr>
<td>
<td>
<button id="Button2" style="width:60" onclick="return show()" value="kharid">shoe data </button>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function show()
{
var p=document.getElementById('p1');
alert(p.value);
var p1=document.getElementById('lproducts');
alert(p1.innertext);
}
function show1()
{
var p1=document.getElementById('p1');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList RepeatColumns="2" GridLines="Both" DataKeyField="Pk_id" Width="100%"
runat="server" ID="ListProducts"
>
<ItemTemplate>
<table dir="rtl" >
<tr>
<td>
<input id="p1" runat="server" onclick="return show()" type="button" value='<%#bind("Product") %>' />
<asp:Label ID="lproducts" Text="<%#bind('Product') %>" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td>
<img id="imgproduct" height="50" width="40" runat="server" src="<%#bind('Url') %>" alt="<%#bind('Product') %>" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="ltozihat" Text="<%#bind('Tozihat') %>" runat="server" ></asp:Label>
</td>
</tr>
<tr>
<td>
قیمت : <asp:Label ID="lbl" Text="<%#bind('Price') %>" runat="server" ></asp:Label>
<br />
</td>
</tr>
<tr>
<td>
<td>
<button id="Button2" style="width:60" onclick="return show()" value="kharid">shoe data </button>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>