Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8993755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:15:55+00:00 2026-06-15T23:15:55+00:00

Following is my JavaScript code for cloning: function addCloneRow(obj) { if(obj) { var tBody

  • 0

Following is my JavaScript code for cloning:

function addCloneRow(obj) {                                
        if(obj) {               
            var tBody = obj.parentNode.parentNode.parentNode;                        
            var trTable = tBody.getElementsByTagName("tr")[tBody.getElementsByTagName("tr").length-1];                        
            var trClone = trTable.cloneNode(true);            
            if(trClone) {      
                var txt  = trClone.getElementsByTagName("input");                
                var srno  = trClone.getElementsByTagName("label");
                var dd   = trClone.getElementsByTagName("select");                                   

                for(var i=0; i<dd.length; i++) {
                    dd[i].options[0].selected=true;
                    var nm = dd[i].name;                    
                    var nNm = nm.substring((nm.indexOf("_")+1),nm.indexOf("["));                                        
                    dd[i].name = nNm+"[]";                    
                }                
                for(var j=0; j<txt.length; j++) {
                    var nm = txt[j].name;                    
                    var nNm = nm.substring((nm.indexOf("_")+1),nm.indexOf("["));                    
                    txt[j].name = nNm+"[]";                            
                    if(txt[j].type == "hidden"){ 
                        txt[j].value = "0"; 
                    }else if(txt[j].type == "text") {               
                        txt[j].value = "";              
                    }else if(txt[j].type == "checkbox") {               
                        txt[j].checked = false;
                    }
                }                   
                tBody.insertBefore(trClone, tBody.getElementsByTagName("tr")[tBody.getElementsByTagName("tr").length]);
            }
        }
    }

and Following is my HTML code:

<table id="step_details" style=" padding: 0px; margin: 5px; border-color: #fff;" align="center" frame="box" cellspacing="15">
        <tr>            
            <th width="45%">Step details</th>
            <th>Expected Results</th>
            <th width="25">Execution</th>
            <th><img src="gui/themes/default/images/ico_add.gif" onclick="addCloneRow(this);"/></th>            
        </tr>
        {foreach from=$gui->viewSteps item=step_info }
        <tr>            
            <input type="hidden" name="existing_id[]" value="{$step_info->id}">
                <td><textArea id="step_details" name="step_details[]">{$step_info->actions|strip_tags|trim}</textArea></td>
                <td><textArea id="expected_results" name="expected_results[]">{$step_info->expected_results|strip_tags|trim}</textArea></td>
                <td style="vertical-align: top;">

                    <select onchange="content_modified = true"  name="etype[]">
                        <option {if $step_info->execution_type eq  1 }selected="selected"  {/if} value="1" label="Manual">Manual</option>
                        <option  {if $step_info->execution_type eq  2 } selected="selected"  {/if}  value="2" label="Automated">Automated</option>
                    </select>
                </td>
                <td style="vertical-align: top;"><img src="gui/themes/default/images/ico_del.gif" onclick="removeCloneRow(this);"/></td>
        </tr>                
        {/foreach} 
        {if $smarty.post.doAction neq "edit"}
        <tr>            
            <td><textArea name="step_details[]"></textArea></td>
            <td><textArea name="expected_results[]"></textArea></td>
            <td style="vertical-align: top;">
                <select onchange="content_modified = true"  name="etype[]">
                    <option selected="selected" value="1" label="Manual">Manual</option>
                    <option value="2" label="Automated">Automated</option>
                </select>
            </td>
            <td style="vertical-align: top;"><img src="gui/themes/default/images/ico_del.gif" onclick="removeCloneRow(this);"/></td>
        </tr>
        {/if}   
    </table>

The cloning is working properly but the issue is if I am on editing page then its cloning it with textarea value instead I want blank value in textarea. How can I add blank value dynamically after cloning in textarea.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:15:57+00:00Added an answer on June 15, 2026 at 11:15 pm

    After the following line:

    var dd   = trClone.getElementsByTagName("select");
    

    put these lines:

    var textarea   = trClone.getElementsByTagName("textarea");
    for(var i=0; i<textarea.length; i++) {
       textarea[i].value = '';
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JavaScript code: var cILo=true; var img1=images/title-2a.png; var img2=images/title-2b.png; function loadblinker()
I have the following JavaScript code: var xmlHttpReq = getXmlHttpObject(); xmlHttpReq.onreadystatechange=function(){ if (xmlHttpReq.readyState ==
Following javascript code: <script type=text/javascript charset=utf-8> function goForLogin() { var xmlhttp; xmlhttp=new XMLHttpRequest(); xmlhttp.open(POST,/account/login,true);
Consider the following Javascript code: var a = []; var f = function() {
I have the following javascript code: function delete_draft(id, name) { var text = 'Are
I'm using the following javascript code to display xml/xsl: function loadXMLDoc(fname) { var xmlDoc;
The following javascript code [ jsfiddle ]: Array.prototype.remove = function(from, to) { var rest
I have the following JavaScript code: <script type='text/javascript'> var v2=xxxxx; var v7=unescape(%2%3432jklsjdkls%); var v5=v2.length;
I have the following Javascript code that works perfectly: $(document).ready(function() { $(#Select1).setDefault(); $(#Select2).setDefault(); $(#Select3).setDefault();
I have the following JavaScript code: var x = ['CFMG','JMFMG','CPMAF']; var y = $.param({'test':x});

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.