Trying to get rid of double quotes

I am trying to get rid of double quotes that are getting displayed at a particular place in my UI code when I don’t have anything to display over there. To explain more, please consider the following code :

<div class="status-latest">
   <div class="status-label">Workflow status:</div>
   <div class="status-value" id="workflow_status"></div>
   <button class="btn btn-success btn-xs" id="edit_employee_workflow_status" alt="Edit workflow status">EDIT</button>
   <button class="btn btn-primary btn-xs" id="reviewstatus_history_link" alt="View workflow history">HISTORY</button>
   <span id="workflow_status_info"></span>
</div>
<div class="status-details">
   <div class="details-who-when">
      <span class="status-person" id="reviewstatus_reviewed_by"></span>
      <span class="status-date" id="reviewstatus_reviewed_on"></span>
   </div>
   <div class="status-comment" id="reviewstatus_comment"></div>
</div>

I am mainly concerned with the reviewstatus_comment of the following div :

<div class="status-comment" id="reviewstatus_comment"></div>

The corresponding Javascript code that I am using is as follows:

var workflowComment = "test";
if (workflowComment) {
    workflowComment = "\"" + workflowComment + "\"";
} else {
    workflowComment = "";
}

$_("#reviewstatus_comment").html("\"" + workflowComment + "\"");

So say for example, the the variable workflowComment which has test value right now doesn’t have any value. My UI code displays "" .

I tried removing the else statement from the above code, I mean else { workflowComment = ""; } and then I noticed it’s printing "null" , that is printing null inside the double quotes.

Is there any way I could not have anything displayed when I don’t have anything to show for the variable workflowComment ? I don’t want to display double quotes at all. Please advise.

Thanks

The problem is that you add double quotes when you actually display the comment:

$_("#reviewstatus_comment").html("\"" + workflowComment + "\"");

As you already add the double quotes around the comment if it has some content, couldn’t you remove them from the final line?

$_("#reviewstatus_comment").html(workflowComment);

Yes, this works. I didn’t realize that. Thanks very much !

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.