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

Attaching event

Status
Not open for further replies.

PoppapumpJ

Programmer
Dec 17, 2001
86
US
Can anyone tell me why this does not work. It looks the same as other examples, however the function does not execute when the event happens

The addRow function is called from a row in a table. It is creating another row for that table

[tt]
<script>
function ShowMenu(){
alert('got here');
}

function addRow(){
//alert(&quot;got here&quot;)
var numRows = document.all.testTable.rows.length
var newRow = document.all.testTable.insertRow(numRows - 1)
var newButton = document.createElement (&quot;button&quot;)
var newInput = document.createElement(&quot;input&quot;)

newInput.setAttribute(&quot;name&quot;, &quot;text1&quot;)
newInput.setAttribute(&quot;id&quot;, (&quot;text&quot; + numRows))

newButton.setAttribute(&quot;value&quot;, &quot;Select Reason Code&quot;)
newButton.attachEvent(&quot;onClick&quot;, ShowMenu)

newRow.insertCell(0)
newRow.insertCell(1)

newRow.cells(0).appendChild(newInput);
newRow.cells(1).appendChild(newButton);

}
</script>

[/tt]

Thanks for the help
 
Can you believe this?

the problem was from the Cap letter in the event name.

so instead of onClick, I should use onclick.

I thought the Javascript standard was lowercase first word and uppercase first letter of every other word.

Just one of those things I guess.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top