Hello Friends,
I am new on this site.
I am developing an appi. where I need to add textboxes at runtime in a <div>.
On one button click, I call the following function (Javascript):
As you can see, the function adds 2 labels, 2 textboxes and 1 button in a <div> element. I also want to call another functin on click of the new created button and henced, event is also atached. But the code is not working.
I get error. on line var fromLbl=documen t..... Line. It says Expected '.' I can't figure out the problem.
If you guys can help me figure out the problem, I would be very glad. Any help is appreciated. I need to resolve this ASAP. Hoping to hear from you all experts soon.
Thanks
I am new on this site.
I am developing an appi. where I need to add textboxes at runtime in a <div>.
On one button click, I call the following function (Javascript):
Code:
function createDrivePanel() {
var odiv = document.getElementById('directDIV');
odiv.innerHTML = "":
var fromLbl=document.createElement("<label for='drFrom'>Drive From: </label>");
var toLbl=document.createElement("<label for='drTo'>Drive To: </label>");
var fromTxt=document.createElement("<input type='text' id='DriveFromTxt' name='DriveFromTxt' value='' />");
var toTxt=document.createElement("<input type='text' id='DriveToTxt' name='DriveToTxt' value='' />");
var getBtn=document.createElement("<input type='button' id='getDirectionsBtn' name='getDirectionsBtn' value='Get Directions' />");
getBtn.attachEvent("onclick", GetDirections1(DriveFromTxt.text, DriveToTxt.text));
alert("all elements Inits");
odiv.appendChild(fromLbl);
odiv.appendChild(fromTxt);
odiv.appendChild('<br>');
odiv.appendChild(toLbl);
odiv.appendChild(toTxt);
odiv.appendChild('<br>');
odiv.appendChild(getBtn);
document.getElementById('directDIV').innerHTML = odiv;
}
function GetDirections1(from, to) {
// ResultsPanel.Controls.Add("Drive From " + from + "Drive To " + to);
alert("Drive From " + from + "Drive To " + to);
}
I get error. on line var fromLbl=documen t..... Line. It says Expected '.' I can't figure out the problem.
If you guys can help me figure out the problem, I would be very glad. Any help is appreciated. I need to resolve this ASAP. Hoping to hear from you all experts soon.
Thanks
Comment