Ask a Question related to Macromedia Dynamic HTML, Design and Development.
-
TGuthrie #1
Adding a function to a button
I'm trying to attach a javascript funtion to a button and I am having problems
with it. Original the javascript function is attached to a dynamically created
text string. Well when I want to attach the same function to the button it
won't work, let me know what to do make this button work with the function.
~~~~~Script~~~~~
function addRowClass(tableID, tableBody, instructionArray)
{
// write add link to page
var oTable = document.getElementById(tableID);
if(oTable)
{
// make the link
oAddLink = document.createElement("a");
oAddLink.setAttribute("href", "#");
oAddLink.onclick = function() { addFormRow(tableBody, instructionArray);
return false; }
var oLinkText = document.createTextNode("Add Another Row");
oAddLink.appendChild(oLinkText);
document.body.insertBefore(oAddLink, document.body.firstChild);
}
}
/* main function */ <--The Function I want to attach to button
function addFormRow(tableBody, fieldArray)
{
tableBody = document.getElementById(tableBody);
newRow = document.createElement("tr");
rowNum = tableBody.getElementsByTagName("tr").length - 1; <-- ****The
Error****
for (var i = 0; i <= fieldArray.length; i++)
{
oCell = document.createElement("td");
oInput = document.createElement("input");
switch(fieldArray[0][i])
{
case "text":
createTextbox(fieldArray[2][i], rowNum, fieldArray[1][i], fieldArray[3][i]);
break;
default:
//an input error has occurred. Nothing will be written out to the cell.
break;
}
oCell.appendChild(oInput)
newRow.appendChild(oCell)
}
rowNum += 1;
tableBody.appendChild(newRow)
}
~~~~ERROR~~~~
Line 149 * <-- ****The Error**** Located in the script
"Null" is null
~~~~My Button~~~~
<input type="button" name="Button1" value="Create Row" class="NewRowButton"
value="javascript=addFormRow()">
~~~~End~~~~~
Thanks for the help
TGuthrie Guest
-
Adding paypal button
I've just switched to Contriubte CS3 and can't figure out how to add the paypal button. Anybody know????????? -
Dynamically adding Dropdown, Text Box, Add Button and Remove Button
Hi Everyone, I am facing a poblem in creating a row which contains following scenario in ASP.NET |DROP_DOWN_LIST | |TEXT_BOX| ... -
Adding a second button if the first button is clicked
Hi I build my form dynamically in Page_Load, with a button If the user clicks the button I want to create another button. I can do this but the... -
adding lingo to a flash button
hey guys. i need to be able to add some lingo to a flash button. the lingo needs to establish the global sound setting for multiple .dxr movies, and... -
Adding javascript function to update button in datagrid edit row
I'd like to run a javascript function when you click the update button on an edit row, but I've no idea how I'd set it. Can't find any examples,... -
robhuddles #2
Re: Adding a function to a button
The function has two arguments - tableBody and fieldArray - that need to get
passed to it when it is called.
Also, your button has two value attributes, which is going to cause problems.
What you want is:
<input type="button" name="Button1" value="Create Row" class="NewRowButton"
onClick="javascript:addFormRow(some_reference_for_ tableBody,
some_reference_for_fieldArray)">
Rob Huddleston
Adobe Dreamweaver Certified Developer
robhuddles Guest



Reply With Quote

