Search code examples
phpjavascripthtmliframeonline-forms

How to Create an Online Form That Opens Web Pages After Clicking the Submit Button


I want to make a form where I can input a domain name and then click the submit button and have the domain name incorporated into part of a search result URL from places like Google, Bing, Yahoo, etc. After clicking the submit button I would like the results to be shown on the bottom of the page using iframe.

EDIT: Instead of opening new tabs, I would like the results to be shown on the bottom of the page using iframe. Is this possible? Here is the updated code so far:

<!DOCTYPE html>
<html>
<head>
<title>Domain Checker</title>
<meta name="description" content="Get useful information about a domain name." />
</head>
<body>

<h1>Domain Checker</h1>
<p>Use the domain checker to get useful information about a domain name. Type the domain name you want to check and hit enter.</p>

<script type='text/javascript'>
function openWindow(url)
{
  var domain2 = document.getElementById('domain2').value;
  window.open(url + domain2);
}
</script>

<form method='post'>
<label>Domain</label><input type='text' name='domain2' id='domain2'>
 <select name="select" onChange="openWindow(this.options[this.selectedIndex].value)">
  <option>Choose Below</option>
  <option value="http://www.dmoz.org/search?q=">DMOZ</option>
  <option value="https://flippa.com/valuation/">Flippa</option>
  <option value="http://web.archive.org/web/*/">WayBack</option>
  <option value="http://www.alexa.com/siteinfo/">Alexa</option>
  <option value="https://www.google.com/search?&q=site:">Google Index</option>
  <option value="https://www.google.com/search?&q=link:">Google Backlinks</option>
  <option value="http://search.yahoo.com/search?p=site:">Yahoo Index</option>
  <option value="http://search.yahoo.com/search?p=link:">Yahoo Backlinks</option>
  <option value="http://www.bing.com/search?q=site:">Bing Index</option>
  <option value="http://www.bing.com/search?q=site:">Bing Backlinks</option>
  <option value="http://whois.domaintools.com/">Whois Info</option>
 </select>
 </form>
<hr>
<p>Results show here in iframe.</p>
</body>
</html>

Solution

  • For the other question in the comment.

    <script type='text/javascript'>
    function openWindow(url)
    {
      var domain = document.getElementById('domain').value;
      //window.open(url + domain);
      document.getElementById('frame').src=url+domain;
    }
    </script>
    
    <form method='post'>
    <label>Domain</label><input type='text' name='domain' id='domain'>
     <select name="select" onChange="openWindow(this.options[this.selectedIndex].value)">
      <option value="http://www.dmoz.org/search?q=">DMOZ</option>
      <option value="https://flippa.com/valuation/">Flippa</option>
      <option value="http://web.archive.org/web/*/">WayBack</option>
      <option value="http://www.alexa.com/search?q=">Alexa</option>
      <option value="https://www.google.com/search?&q=site:">Google</option>
     </select>
     </form>
    
     <iframe id="frame">Your browser does not support iframes.</iframe>