KeithMcElroy
asked on
javascript: change the onClick event dynamically
The onClick event is dynamically created at load time. Inside the onclick event is a value similar to the following table_field_1. Each time a new row is created, the onclick event needs to have table_field_1 changes to table_field_2, table_field_3 and so on.
The code I included has issues because the getAttribute("onCick") returns the keyword function. If I could get it to return just the actual content of the onClick, I think it could work.
Need help shaping this solution.
The code I included has issues because the getAttribute("onCick") returns the keyword function. If I could get it to return just the actual content of the onClick, I think it could work.
Need help shaping this solution.
if(els[el].id.indexOf("anchor") > -1)
{
//sample code that needs to be manipulated...
// onClick=cal.select(document.forms['WebForm']." & fieldelement.getAttribute("id") & ",'anchor1','MM/dd/yyyy'); return false
//retrieve the onClick event as text and determin the begin and end point for the number following the last underscore
//var starttargpos = els[el].getAttribute("onClick").lastIndexOf("_")
//var stoptargpos = els[el].getAttribute("onClick").indexOf(",'anchor1")
//parse out the text to the left and the text representing the number to be changes
//lefttext = els[el].getAttribute("onClick").substring(0,starttargpos - 1)
//targettext = els[el].getAttribute("onClick").substring(starttargpos,stoptargpos)
//increment the number and retrieve the text to the right
//newtargettext = Number(targettext) + 1
//righttext = els[el].getAttribute("onClick").substring(stoptargpos + 1)
//reassemble the left, target and right together and assign to the onClick attribute
//newonclick = lefttext + newtargettext + righttext
//els[el].getAttribute("onClick") = els[el].getAttribute("onClick")
}
have you tried seeing what getAttribute("onCick").val ue returns?
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.