String HTML node methods

Enter a string

Your string
Bold
Italic
A copy of the JavaScript functions:

// sample-7-html.js
// This sample shows String character methods

function reset_values()
  {
  var output1 = document.getElementById("output1");
  output1.value = null;
  output1.focus();
  }

function change_values()
  {

  // text_from_1 is used in the following sections
  var output1 = document.getElementById("output1");
  var string_object = new String(output1.value);
  var text_from_1 = string_object.toString();

  // original text
  var outputx = document.getElementById("outputx");
  var my_text_x = document.createTextNode(text_from_1);
  if(outputx.childNodes.length > 0 )
    {
    outputx.removeChild(outputx.firstChild);
    }
  outputx.appendChild(my_text_x);

  // bold text
  var outputy = document.getElementById("outputy");
  var bold_text_node = document.createTextNode(text_from_1);
  var my_bold_node = document.createElement("b");
  my_bold_node.appendChild(bold_text_node);
  if(outputy.childNodes.length > 0 )
    {
    outputy.removeChild(outputy.firstChild);
    }
  outputy.appendChild( my_bold_node );


  // Italic text
  var outputz = document.getElementById("outputz");
  outputz.innerHTML = "<i>"+text_from_1+"</i>";

  }