Jangrina Posted July 16, 2013 Share Posted July 16, 2013 Hi All, I created input text in a JavaScript function. When I try in browser, I cannot enter text into those fields. Can someone tell me why and how to solve this? HTML File In this file, a function crtTable() will be called to create rows, columns and input. <form id="frmDetails" name="form1"><table id="tblDetails" border="1"><tr> <td>YEAR</td> <td><input class="txtName" type="TEXT" name="year" id="year"></td> <td></td></tr><tr> <td>NAME 1</td> <td><input class="txtName" type="TEXT" name="name1" id="name1"></td> <td></td><tr><tr> <td>NAME 2</td> <td><input class="txtName" type="TEXT" name="name2" id="name2"></td> <td id="adder" onclick="addRow()">[+]</td></tr></table> <!--tblDetails--><br><input type="button" value="Create Table" onclick="crtTable()"></form><p id="pDetails"></p><table id="tblTax" border="1"><tbody id="btblTax" onclick="crtTable()"></tbody></table> <!--tblTax--> JavaScript All the input text created in below code, cannot be inserted with text. Pls help. // row 2 var tr2 = tbody.insertRow(-1); var td1 = tr2.insertCell(-1); td1.innerHTML = "Adjusted Income"; var td2 = tr2.insertCell(-1); var inp1 = document.createElement("input"); // input Adjusted Income 1 inp1.name = "inpAdjIncome1"; inp1.id = "inpAdjIncome1"; inp1.className = "txtCalc"; td2.appendChild(inp1); var td3 = tr2.insertCell(-1); var inp2 = document.createElement("input"); // input Adjusted Income 2 inp2.name = "AdjIncome2"; inp2.id = "AdjIncome2"; inp2.className = "txtCalc"; td3.appendChild(inp2); var td4 = tr2.insertCell(-1); td4.innerHTML = ""; var td5 = tr2.insertCell(-1); td5.innerHTML = ""; if (numOfName > 2) { for (i=3; i<=numOfName; i++) { td = tr2.insertCell(-1); td.innerHTML = ""; } } // row 3 var tr3 = tbody.insertRow(-1); var td1 = tr3.insertCell(-1); td1.innerHTML = "+ Balancing Charge"; var td2 = tr3.insertCell(-1); var inp1 = document.createElement("input"); // input Balancing Charge 1 inp1.name = "BalCharge1"; inp1.id = "BalCharge1"; inp1.className = "txtCalc"; td2.appendChild(inp1); var td3 = tr3.insertCell(-1); var inp2 = document.createElement("input"); // input Balancing Charge 2 inp2.name = "BalCharge2"; inp2.id = "BalCharge2"; inp2.className = "txtCalc"; td3.appendChild(inp2); var td4 = tr3.insertCell(-1); td4.innerHTML = ""; var td5 = tr3.insertCell(-1); td5.innerHTML = ""; Link to comment Share on other sites More sharing options...
dsonesuk Posted July 16, 2013 Share Posted July 16, 2013 I notice you have not define type in your creation of inputs, try that. Link to comment Share on other sites More sharing options...
Jangrina Posted July 16, 2013 Author Share Posted July 16, 2013 i tried inp1.type = "text"; still cannot. I read somewhere type is optional. It will default to text when not specified. Not sure whether this fact is correct or not. Link to comment Share on other sites More sharing options...
jeffman Posted July 16, 2013 Share Posted July 16, 2013 (edited) Ignore this post. I see from your other thread ON THIS SAME TOPIC that the problem is resolved. Edited July 16, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
Jangrina Posted July 16, 2013 Author Share Posted July 16, 2013 (edited) Did you really read the prob? The TOPIC is so much different, so, is the problem. The thread that was resolved was something about adding rows. And the topic resolved was "Problem with Add Row Dynamically". Can't you see the difference? But this thread is about Input Text. My input text cannot work. They cant receive input. If you don't want to help, don't say something like that. Edited July 16, 2013 by Jangrina Link to comment Share on other sites More sharing options...
jeffman Posted July 17, 2013 Share Posted July 17, 2013 Sorry for the misunderstanding. I did want to help. I posted a long response. When I thought your problem was solved, I deleted the text because the forum does not allow me to delete the post. So I tried to explain why my post was there but didn't say anything. Anyway, when I execute your code in Firefox, it creates a table, and the inputs accept text. When you say the inputs don't accept text, do you mean that when a user types, nothing appears? If a user clicks on the input, does the cursor begin to flash there? It would be helpful if you post all the code or a link to your page. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now