title: how to escape special characters within eval using javascript?
body: <pre><code>var input;
  
  // method 1
  input = document.getElementById('address').value;
  alert(input)
  
  // method 2
  eval('input = "'+document.getElementById('address').value+'"')
  alert(input)
  </code></pre>
  
  <p><strong>method 1 is working</strong> fine, but <strong>method 2 is not working</strong> when <strong>newline</strong> characters are inputted and it says <strong>"unterminated string literal"</strong>.</p>
  
  <p>I need to store values using <strong>eval</strong> anyway. So please help me.</p>