0

I have an input text field in HTML. I want to put the value reg query "HKEY_CLASSES_ROOT\mailto\shell\open\command" into the input field when my page loads.

If I do <input readonly="readonly" type='text' id="john" value="reg query "HKEY_CLASSES_ROOT\mailto\shell\open\command""> Then the input field dispays

reg query

Then I tried escaping using a backslash for every double quote and slash like so,

<input readonly="readonly" type='text' id="john" value="reg query \"HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command\"">

The result I get is not at all satisfactory

reg query \

I managed to find a workaround which is rather too much I feel . the work-around is

<!doctype html>
<html>
<head>
    <title>Issues with values</title>

 <script>
  function show()
  {
  document.getElementById('john').value = "reg query \"HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command\"";
  }
</script>

<body>
text :  <input readonly="readonly" type='text' id="john" value="reg query \"HKEY_CLASSES_ROOT\\mailto\\shell\\open\\command\""> 
    <button id='1' onClick="show()">Start time</button>
</body>
</html>

On clicking the button I get the desired output

reg query "HKEY_CLASSES_ROOT\mailto\shell\open\command"

Question is how to put/parse/escape that value inside the input value as a default???

DannyBoi
  • 636
  • 1
  • 7
  • 23

0 Answers0