Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help!!! Dynamic HTML Button

Status
Not open for further replies.

NJLDoc

Programmer
Jan 25, 2002
93
0
0
I have a page that requires dynamic buttons. I need buton1 to increment a value in textbox1 and button2 to increment textbox2 and so on. The values of the buttons are derived from a database. If I use ASP buttons, each time a button is clicked the whole page reposts causing an on screen flash effect. If I use HTML buttons where no post or screen flash occurs, I can return the value of the button through alert but cannot increment the required textbox.

Scenario:

Button1 = Book A, textBox1 = 3
Button2 = Book B, textBox2 = 1 etc...

I want to, on submit (post okay here causing screen flash), scroll through the text boxes and buttons to compile listing of books with count greater than zero. The number of buttons is determined by the database listing of books so could have several hundred buttons.

 
what have you tried so far?

psst - post your attempt (code you've written that is not working) and someone is almost guaranteed to help, post a scenerio and most people think you're trying to get someone to do your homework for you - in which case the chances of a response are pretty slim.



--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Sorry. A little too old for homework.

The script i can return the clicked button value is:

function whichElement(e)
{
var targ;
if (!e)
{
var e=window.event;
}
if (e.target)
{
targ=e.target;
}
else if (e.srcElement)
{
targ=e.srcElement;
}
if (targ.nodeType==3)
{
targ = targ.parentNode;
}
var tname;
tname=targ.value;
//tname=targ.id;

//dtButtonSubmit(tname);
alert("You selected " + tname + ".");

}

The dynamic code i use is:

Dim i As Integer
Dim dtButtons As DataTable = clsOS_Calculator.GetBookList(False)
Me.Panel1.Width = 650

For i = 0 To dtButtons.Rows.Count - 1
Dim ctl As New Button
Dim sValue As String
With ctl
.Style("Background-color") = "#F3DFBA"
.Style("Width") = Me.Panel1.Width.Value / 3.1
.InnerText = dtButtons.Rows.Item(i).Item("fldArticles").ToString
.ID = "dtButton" & i.ToString
sValue = dtButtons.Rows.Item(i).Item("fldWeight").ToString
.Style("Value") = sValue
.Attributes.Add("onmousedown", "whichElement(event)")
.Attributes.Add("runat", "server")
.Attributes.Add("Value", sValue)
.Attributes.Add("BookTitle", sValue)
.Attributes.Add("Index", i)
.Attributes.Add("Title", "BookTitle: " & sValue & " lbs") 'This is ToolTip
End With
Me.Panel1.Controls.Add(ctl)
Next
 
That looks like VB.NET code for ASP.NET - this is a Classic ASP forum (i.e. Server side VBScript).

Maybe try here:


--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top