Advertisement

11.01.2007 at 01:01PM PDT, ID: 22933336
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Set onclick event with javascript when duplicating table row

Asked by pwtucker in JavaScript

Tags: , , ,

Hi Experts,
I need some more help.  I have a table with 4 columns and when the user clicks on a button it duplicates the first row.  However, I need to change the onclick event of the new row to be onclick="selectTime(this,field[nextrownumber])".  The problem is that when the new field is created it increases the number at the end of each field, so the copied onclick event is not working correctly.   How can I create this onclick event ("selectTime(this,txtStartTime1)") so that txtStartTime1 becomes txtStartTime[newrownumber]?

Here is the code I am using to create the new row.  The function selectTime is in a referenced js file if that makes a difference.


    <script language="JavaScript" src="js/timepicker.js"></script>

<script language="JavaScript">

function AddRow()
    {                  
            var dColor = '#E5E5E5';  
            var eColor = '#FFFFFF';                      
            var idImg=["deleteStart","StartImg","StopImg"];
            var idText=["chkSelectStartTime","txtStartTime", "txtStopTime", "txtStartStopComments"];            
            var tbl = document.getElementById('StartStop');  
            var ctr = tbl.rows.length;
            if(tbl.rows.length == 7)
            {
                alert("Not allowed to enter more start/stop times to this time sheet.  Please submit this timesheet and create another for more records.");
                return false;
            }
            var tbd = tbl.getElementsByTagName('tbody')[0];
            var r = tbl.getElementsByTagName('tr');
            var c = r[1].cloneNode(true)
           
            var sel = c.getElementsByTagName('img');
            for(var i = 0;i<sel.length;i++)
            {                          
              sel[i].name = idImg[i] + ctr;
              sel[i].id = idImg[i] + ctr;
              if(sel[i].name == 'chkSelectStartTime' + ctr)
                {
                    sel[i].disabled = false;
                    sel[i].alt = "Click icon to delete row.";
                    sel[i].style.backgroundColor = eColor;
                    sel[i].style.cursor = 'hand';                    
                }                                                        
            }

            var sel = c.getElementsByTagName('input');
            for(var i = 0;i<sel.length;i++)
            {                  
                  sel[i].disabled = false;
                  sel[i].name = idText[i] + ctr;
                  sel[i].id = idText[i] + ctr;
                  sel[i].value = "";                                    
            }

            tbd.insertBefore(c,tbl.rows[tbl.rows.length - 1]);
    }

</script>
</head>

    <body>
    <form id="TimeSheet">  

<input id="btnAdd" name="btnAdd;" onclick="AddRow()"
            style="width: 75px; height: 22" type="button" value="Add Row">      
        <table id="StartStop" cellpadding="0" cellspacing="0" style="border-right: LightSteelBlue  thin solid;
            border-top: LightSteelBlue  thin solid; border-left: LightSteelBlue  thin             solid;
            border-bottom: LightSteelBlue  thin solid; border-collapse: collapse;">
            <tr>
                <th style="width: 13px; height: 15px; border-bottom: LightSteelBlue                      thin solid;
                    border-right: LightSteelBlue  thin solid; background-color: AntiqueWhite">
                </th>
                <th style="width: 95px; height: 19px; border-bottom: LightSteelBlue  thin                solid;
                    border-right: LightSteelBlue  thin solid; background-color: AntiqueWhite">
                    Start Time</th>
                <th style="width: 95px; height: 19px; border-bottom: LightSteelBlue  thin                solid;
                    border-right: LightSteelBlue  thin solid; background-color: AntiqueWhite">
                    Stop Time</th>
                <th style="width: 250px; height: 15px; border-bottom: LightSteelBlue                      thin solid;
                    border-right: LightSteelBlue thin solid; background-color: AntiqueWhite">
                    Comments</th>
            </tr>
           
            <tr>
                <td align="center" style="width: 13px; height: 15px; border-bottom: LightSteelBlue thin solid;
                    border-right: LightSteelBlue thin solid">
                    <input id="chkSelectStartTime1" name="chkSelectStartTime1" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);"
                        style="width: 13px; height: 15px; border: 0" type="checkbox" /></td>
                <td style="width: 129px; height: 19px; border-bottom: LightSteelBlue  thin                solid;
                    border-right: LightSteelBlue  thin solid">
                    <input id="txtStartTime1" maxlength="8" name="txtStartTime1"
                        readonly="readonly" size="8" style="width: 95px; height: 19px; border: 0;" type="text"
                        value="" />
                    <img name="StartImg1" alt="Pick a Start Time" border="0" height="19px" onclick="selectTime(this,txtStartTime1)"
                        src="images/timepicker.gif" style="cursor: hand" width="30">
                </td>
                <td style="width: 129px; height: 19px; border-bottom: LightSteelBlue  thin                solid;
                    border-right: LightSteelBlue  thin solid">
                    <input id="txtStopTime1" maxlength="8" name="txtStopTime1"
                        readonly="readonly" size="8" style="width: 95px; height: 19px; border: 0;" type="text"
                        value="" />
                    <img name="StopImg1" alt="Pick a Stop Time" border="0" height="19px" onclick="selectTime(this,txtStopTime1)"
                        src="images/timepicker.gif" style="cursor: hand" width="30">
                </td>  
                <td style="width: 250px; height: 15px; border-bottom: LightSteelBlue                      thin solid;
                    border-right: LightSteelBlue  thin solid">
                    <input maxlength="195px" name="txtStartStopComments1" style="width: 250px; height: 19px; border: 0"
                        type="text" />
                </td>            
            </tr>
            <tr style="visibility:hidden"><td></td></tr>
        </table>
Start Free Trial
 
Loading Advertisement...
 
[+][-]11.01.2007 at 01:09PM PDT, ID: 20196266

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:13PM PDT, ID: 20196288

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:27PM PDT, ID: 20196375

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:29PM PDT, ID: 20196389

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:33PM PDT, ID: 20196411

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:34PM PDT, ID: 20196418

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:37PM PDT, ID: 20196458

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:43PM PDT, ID: 20196501

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: javascript, onclick, event, set
Sign Up Now!
Solution Provided By: Zvonko
Participating Experts: 3
Solution Grade: A
 
 
[+][-]11.01.2007 at 01:45PM PDT, ID: 20196527

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:51PM PDT, ID: 20196566

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:53PM PDT, ID: 20196581

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:56PM PDT, ID: 20196601

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 01:59PM PDT, ID: 20196615

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 02:01PM PDT, ID: 20196635

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 02:09PM PDT, ID: 20196711

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 02:11PM PDT, ID: 20196720

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.01.2007 at 02:14PM PDT, ID: 20196741

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628