Whing Dela Cruz
asked on
Insert Button on a table
Hi experts, I wish to insert button on a table while on looping. I want a button to be created between Proname and Price. Is it possible? like the code bellow I want to insert this between Proname and Price <td><button class="Addbutton">myButton </button>< /td>
Set rs = cn.Execute("Select Procode, Proname, Price from Stock")
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
<tr class="header1">
<th style="width:2%;">Procode< /th>
<th style="width:90%;">Proname </th>
<th style="width:4%;">myButton </th>
<th style="width:4%;">Price</t h>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.val ue)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
cn.close
end if
%>
</table>
Set rs = cn.Execute("Select Procode, Proname, Price from Stock")
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
<tr class="header1">
<th style="width:2%;">Procode<
<th style="width:90%;">Proname
<th style="width:4%;">myButton
<th style="width:4%;">Price</t
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.val
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
cn.close
end if
%>
</table>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok I'm out at the moment, when I get back I'll get to finish this up today or tomorrow at the latest.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI Guys, All solutions are useful and best to me, but i choose heilo's solution. Thanks a lot for your brilliant brain. More power and God bless you all!
ASKER
Hi Julian, If you don't mind, I wish to use your solution given above but I'm having error says, "Syntax error." This is your code from above solution. Thank you!
<td><%Response.Write(rs('P rocode')%> )</td>
<td><%Response.Write(rs('P
>> 'Procode'
In VBScript, you use an apostrophe as a line comment, so you need to change the apostrophes to double quotes:
<td><%Response.Write(rs("P rocode")%> )</td>
In VBScript, you use an apostrophe as a line comment, so you need to change the apostrophes to double quotes:
<td><%Response.Write(rs("P
ASKER
Hi hielo, i changed it to this, <td><%Response.Write(rs("P rocode"))% ></td> but an error says,
Error Type:
Response object, ASP 0104 (0x80070057)
Operation not Allowed
/Index1.asp
Error Type:
Response object, ASP 0104 (0x80070057)
Operation not Allowed
/Index1.asp
ASKER
I also tried to use this code below and I've got the same error
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
<%do until rs.EOF%>
<tr>
<td><button class="Addbutton">myButton </button>< /td>
</tr>
<%loop
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
<%do until rs.EOF%>
<tr>
<td><button class="Addbutton">myButton
</tr>
<%loop
On your original post you have:
You are missing a %> between those lines:
If the problems persist, post the code you are actually using now.
Set rs = cn.Execute("Select Procode, Proname, Price from Stock")
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
You are missing a %> between those lines:
Set rs = cn.Execute("Select Procode, Proname, Price from Stock")
%>
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
Also, on your last post you are not calling rs.MoveNext. Set rs = cn.Execute("Select Procode, Proname, Price from Stock")
%>
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
<tr class="header1">
<th style="width:2%;">Procode</th>
<th style="width:90%;">Proname</th>
<th style="width:4%;">myButton</th>
<th style="width:4%;">Price</th>
</tr>
<%do until rs.EOF%>
<tr>
<td><%Response.Write(rs("Procode")%>)</td>
<td><%Response.Write(rs("Proname"))%></td>
<td><button class="Addbutton">myButton</button></td>
<td><%Response.Write(rs("Price"))%></td>
</tr>
<%
rs.MoveNext
loop
rs.close
cn.close
%>
</table>
If the problems persist, post the code you are actually using now.
ASKER
Hi Heilo, This are the codes..
<div id="Win" class="my-overflow">
<%
dim cn, rs
Set cn = Server.CreateObject("ADODB .Connectio n")
Set rs = Server.CreateObject("ADODB .Recordset ")
cn.ConnectionString = "driver={SQL Server};server=MYSERVER;ui d=;pwd=;da tabase=MyD B"
cn.Open
Set rs = cn.Execute("Select Proname, Procode from STOCK")
%>
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
<%do until rs.EOF%>
<tr>
<td><button class=""Addbutton"" onclick=""return iFunction()"">Add</button> </td>
<td><%Response.Write(rs("P rocode"))% ></td>
<td><%Response.Write(rs("P roname"))% ></td>
</tr>
<%loop
rs.close
cn.close
%>
</table>
</div>
<div id="Win" class="my-overflow">
<%
dim cn, rs
Set cn = Server.CreateObject("ADODB
Set rs = Server.CreateObject("ADODB
cn.ConnectionString = "driver={SQL Server};server=MYSERVER;ui
cn.Open
Set rs = cn.Execute("Select Proname, Procode from STOCK")
%>
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
<%do until rs.EOF%>
<tr>
<td><button class=""Addbutton"" onclick=""return iFunction()"">Add</button>
<td><%Response.Write(rs("P
<td><%Response.Write(rs("P
</tr>
<%loop
rs.close
cn.close
%>
</table>
</div>
<%do until rs.EOF%>
<tr>
<td><button class=""Addbutton"" onclick=""return iFunction()"">Add</button> </td>
<td><%Response.Write(rs("P rocode"))% ></td>
<td><%Response.Write(rs("P roname"))% ></td>
</tr>
<%loop
......
should be:
<%do until rs.EOF%>
<tr>
<td><button class=""Addbutton"" onclick=""return iFunction()"">Add</button> </td>
<td><%Response.Write(rs("P rocode"))% ></td>
<td><%Response.Write(rs("P roname"))% ></td>
</tr>
<%rs.MoveNext
loop
......
<tr>
<td><button class=""Addbutton"" onclick=""return iFunction()"">Add</button>
<td><%Response.Write(rs("P
<td><%Response.Write(rs("P
</tr>
<%loop
......
should be:
<%do until rs.EOF%>
<tr>
<td><button class=""Addbutton"" onclick=""return iFunction()"">Add</button>
<td><%Response.Write(rs("P
<td><%Response.Write(rs("P
</tr>
<%rs.MoveNext
loop
......
>> <td><button class=""Addbutton"" onclick=""return iFunction()"">Add</button> </td>
You need the back-to-back double quotes only if you are within a VBScript block emitting a string -- like the Response.Write() that you were using earlier for that particular line. The way it is now, the onclick will not work. What you need is:
You need the back-to-back double quotes only if you are within a VBScript block emitting a string -- like the Response.Write() that you were using earlier for that particular line. The way it is now, the onclick will not work. What you need is:
<div id="Win" class="my-overflow">
<%
dim cn, rs
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
cn.ConnectionString = "driver={SQL Server};server=MYSERVER;uid=;pwd=;database=MyDB"
cn.Open
Set rs = cn.Execute("Select Proname, Procode from STOCK")
%>
<table id="myTable" style="cursor: pointer" class="one" Width="100%">
<%do until rs.EOF%>
<tr>
<td><button class="Addbutton" onclick="return iFunction()">Add</button></td>
<td><%Response.Write(rs("Procode"))%></td>
<td><%Response.Write(rs("Proname"))%></td>
</tr>
<%
rs.MoveNext
Loop
rs.close
cn.close
%>
</table>
</div>
ASKER
You are right hielo, onclick is now working properly. Thank for your great knowledge. Your different ideas and techniques helps me a lot doing my project. I can't give you points on this great answered but one thing that I would like to say to both of guys is Great Job! More power to both of you and God bless you all!
ASKER