Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
HTML Pages with CSS and JavaScript
dynmicall adding row
pankaj semwal
Ranch Hand
Posts: 303
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Below is my
java
scrip function which adding the row dynamically.But i want to know how i can put CSS on these.Pleas help me.
function addRow() { var tbl = document.getElementById("mySampleTable"); var lastRow = tbl.rows.length; var iteration = lastRow; var row = tbl.insertRow(lastRow); var cellLeft = row.insertCell(0); var e = document.createElement("input"); e.type = "text"; e.name = "timesheet.dateval"; e.value = document.getElementById("dateval").value; cellLeft.appendChild(e); var cellRight = row.insertCell(1); var el = document.createElement("input"); el.type = "text"; el.name = "timesheet.startWorkingtime"; el.id = "startWorkingtime" + iteration; cellRight.appendChild(el); var cellRight1 = row.insertCell(2); var e2 = document.createElement("input"); e2.type = "text"; e2.name = "timesheet.endWorkingtime"; e2.id = "endWorkingtime" + iteration; cellRight1.appendChild(e2); var cellRight2 = row.insertCell(3); var e3 = document.createElement("input"); var e33 = document.createElement("input"); var eBrtag = document.createElement("br"); var textYes = document.createTextNode("Yes"); var textNo = document.createTextNode("No"); e3.type = "checkbox"; e3.value = "Yes"; e3.name = "timesheet.billType"; e33.type = "checkbox"; e33.value = "No"; e33.name = "timesheet.billType"; cellRight2.appendChild(e3); cellRight2.appendChild(textYes); cellRight2.appendChild(eBrtag); cellRight2.appendChild(e33); cellRight2.appendChild(textNo); var cellRight3 = row.insertCell(4); var e4 = document.createElement("select"); e4.name = "timesheet.projectName"; val1 = document.getElementById("projectName"); valT = val1.options[val1.selectedIndex].text; e4.options[0] = new Option(valT, valT); cellRight3.appendChild(e4); var cellRightSel2 = row.insertCell(5); var cellRight4 = document.createElement("select"); cellRight4.name = "timesheet.activity"; cellRight4.options[0] = new Option("Analysis", "Analysis"); cellRight4.options[1] = new Option("Desgining", "Desgining"); cellRight4.options[2] = new Option("Coding", "Coding"); cellRight4.options[3] = new Option("Testing", "Testing"); cellRightSel2.appendChild(cellRight4); var cellRighttextArea = row.insertCell(6); var textAreas = document.createElement("textarea"); textAreas.name = "timesheet.empComments"; textAreas.rows="3"; textAreas.cols="20" cellRighttextArea.appendChild(textAreas); }
Eric Pascarello
author
Posts: 15385
6
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
el.className="foo"; el.style.color = "red";
Eric
pankaj semwal
Ranch Hand
Posts: 303
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks now its working.
But How can i change the alternative background color of dynamically adding row.
Please tell me.
Thanks
Eric Pascarello
author
Posts: 15385
6
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It is easy to do. You set the row's css.
row.style.backgroundColor = (lastRow%2==0)?"red":"yellow";
Eric
Eric Pascarello
author
Posts: 15385
6
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It is easy to do. You set the row's css.
row.style.backgroundColor = (lastRow%2==0)?"red":"yellow";
Eric
Eric Pascarello
author
Posts: 15385
6
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It is easy to do. You set the row's css.
row.style.backgroundColor = (lastRow%2==0)?"red":"yellow";
Eric
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
How to add form fields dynamically
deleteing rows and storing row(text box) values in javascript
Adjusting size of select Box in java script
getting reference of dynamically created field
need help in dyanmically adding drop down box
More...