1

Entering number in searchbox (index.html) and drop in href link (search-pincode.html) inside <span> tag - I've got searchbox value when entering in search-pincode.html but when am trying from index.html page it doesn't work. no luck ! any help appreciated ! thanks in advance.

HTML (index.html)

<form class="form1" role="search" method="get" action="search-pincode.html">
<input class="pincode1" type="number" placeholder="Enter Postcode" id="user-pincode">
<button class="submit" type="button" onclick="myFunction()">Check</button>
</form>

JS

          <script>
              function myFunction() {
              var x = document.getElementById("user-pincode").value;
              document.getElementById("user-pincode-show").innerHTML = x;
              }
         </script>

Output : search-pincode.html

<h1 class="search-h1-contact">Yes, we install CCTV in <span id="user-pincode-show"></span></h1>
jhpratt
  • 6,841
  • 16
  • 40
  • 50
Hameed Basha
  • 149
  • 1
  • 12
  • You are trying to get DOM of another page, how are you opening `search-pincode.html`?! – cнŝdk Nov 17 '17 at 19:15
  • 1
    If User enter the number in searchbox and clicking on button its has to go `search-pincode.html` with that number – Hameed Basha Nov 17 '17 at 19:18
  • Please fix the error that you can see in console of your web browser. Add name attribute to `input#user-pincode`. After submitting the form you can get the value of parameter on the search-pincode.html page using some server side script, for example with PHP it will be GET[] array. For JS look at [this](https://stackoverflow.com/a/979995/7663972) answer. – camelsWriteInCamelCase Nov 17 '17 at 21:06

0 Answers0