You need to sign in to do that
Don't have an account?
vibration
need controller class
need a controller class of following apex page
<body> <form> <table id="TableId"> <thead> <tr> <th scope="col" class="num"></th> <th scope="col" class="fname">Name</th> </tr> </thead> <tbody id="tablebody"> <tr> <td class="num">1.</td> <td><input type="text" name="" value="" id="name1"/></td> </tr> </tbody> <tfoot> <tr> <td><input type="Button" value="Save" onclick="Validate();"/></td> <td colspan="2"> <a onclick="InsertRow();">Add More 1 Records</a> </td> </tr> </tfoot> </table> <script> var AllName = ''; function addRow(num) { if(document.all) { var tbody1 = document.getElementById('tablebody'); var row = document.createElement("TR"); var td1 = document.createElement("TD"); td1.setAttribute("className","num"); td1.innerHTML = num + '.' ; var td2 = document.createElement("TD"); var SpanTd2 = document.createElement("Span"); var aTextBoxSpanTd2 = document.createElement('input'); aTextBoxSpanTd2.type = "text"; aTextBoxSpanTd2.id = "name" + num ; SpanTd2.appendChild(aTextBoxSpanTd2); td2.appendChild(SpanTd2); row.appendChild(td1); row.appendChild(td2); tbody1.appendChild(row); } else { var tbody1 = document.getElementById('tablebody'); var row = document.createElement("TR"); var td1 = document.createElement("TD"); td1.setAttribute("class","num"); td1.innerHTML = num + '.' ; var td2 = document.createElement("TD"); var SpanTd2 = document.createElement("Span"); var aTextBoxSpanTd2 = document.createElement('input'); aTextBoxSpanTd2.type = "text"; aTextBoxSpanTd2.id = "name" + num ; SpanTd2.appendChild(aTextBoxSpanTd2); td2.appendChild(SpanTd2); row.appendChild(td1); row.appendChild(td2); tbody1.appendChild(row); } } function InsertRow() { var table = document.getElementById("TableId"); var strTb = '', rowCount = table.rows.length; var NewId = rowCount-1; for(i = NewId ; i < NewId + 1 ; ++i) { addRow(i); } } function Validate() { var table = document.getElementById("TableId"); var rowCount = table.rows.length; var MyTeam = new Array(rowCount); for(i = 1 ; i <= rowCount-2 ; i++) { var Name = "name" + i; var NameValue = document.getElementById(Name).value; if(NameValue == '') { alert("Name is required in S.no" + " " + i); } else { if(i == 1) { AllName = NameValue; } else { AllName = AllName + ';' + NameValue; } } } alert(AllName); // Pass All name into the controller and separate this string value by ; and insert all the record. } </script> </form> </body> </apex:page>
Could not understand your problem , do you want to do all the actions performed by java script to be done by apex controller.
What you want us to do???
Hi,
You have declared <apex:page> ending tag but you haven't initialised it
Regards,
Praveen