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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reset html generated from subroutine

Status
Not open for further replies.

dlangschied

Technical User
Feb 22, 2012
3
US
Hello!
I have been struggling to find an answer to this issue.

I have an HTA application that has some buttons that create output to the page as html. I have it working, but every time a press a button the it is appended to the existing data. I am using appendchild, but I was really looking to create a new node or remove the old node at the top. My example below is my latest attempt that fails with "Could not complete the operation due to error 800a01b6." I hope someone can help!

<div id="nav">
<table>
<tr>
<td>
<INPUT TYPE="button" NAME="Customer" VALUE="Add Customer" id='AddCustomer' onclick=AddCustomer() width="175" style="width: 175px">
</td>
.
.
.
.
.
Sub AddCustomer
For Each oDiv in data
RemoveNode
Next
set oDiv = document.createElement("div")
addcust = "<TABLE COLSPAN=200 CELLPADDING=1 BORDER=0 WIDTH=500>"
addcust = addcust & "<tr>"
addcust = addcust & "<TD colspan=2 VALIGN=TOP BGCOLOR='#800000'>"
addcust = addcust & "<FONT STYLE='ARIAL NARROW' COLOR='#ffffff' SIZE=2>Customer Data</font>"
addcust = addcust & "</td>"
.
.
.
.
.
.
.
.
addcust = addcust & "</td>"
addcust = addcust & "</tr>"
addcust = addcust & "</table>"

oDiv.innerHTML = addcust
data.appendChild oDiv
End Sub
 
Try having your button call a function. In that function reset the content in the DIV to nothing, then have it add in whatever content you need.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at
Work SMARTER not HARDER.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top