Script not working in post content

Put this markup where you would like to before footer. you can put this markup in page editor text mode too. But doing so will remain in that page alone. so place it in template files.

    Search: <input type="text" id="fname" >
    <a id="sear" href="" target="_blank">Search</a>

write a function and hook it to wp_footer, place the code in funcitons.php.

        function output_custom_script(){
          ?>
          <script>
           document.getElementById('fname').addEventListener('keyup', function() {
    var  x = document.getElementById("fname").value;
    var url = "https://www.google.co.in/search?q=all+"+x+"&biw=1366&bih=643&source=lnms&tbm=isch";
    document.getElementById("sear").href=url;
}, false);
          </script>
         <?php
        }
        add_action('wp_footer','output_custom_script');

Check this Js Fiddle