title: Javascript modification query
body: <p>I'm hoping someone can help me out with a little question.</p>
  
  <p>I have the following code to change combo box entries based on what is selected in the previous box.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Representation of AJAX&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
     function update(str)
     {
     var xmlhttp;
  
     if (window.XMLHttpRequest)
     {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
     }
     else
     {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }    
  
     xmlhttp.onreadystatechange = function() {
      if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200)
      {
        document.getElementById("data").innerHTML = xmlhttp.responseText;
      }
    }
  
    xmlhttp.open("GET","demo.php?opt="+str, true);
    xmlhttp.send();
    }
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
    &lt;select id="optionA" onchange="update(this.value)"&gt;
      &lt;option value="0"&gt;Select...&lt;/option&gt;
      &lt;option value="1"&gt;Option1&lt;/option&gt;
      &lt;option value="2"&gt;Option2&lt;/option&gt;
    &lt;/select&gt;
    &lt;br/&gt;
    &lt;select id="data"&gt;
      &lt;option&gt;Select an Option...&lt;/option&gt;
    &lt;/select&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And </p>
  
  <pre><code>&lt;?php
    $opt = $_GET['opt'];
  
    switch($opt)
    {
      case 0:
      default:
        echo '
              &lt;option&gt;Select an Option...&lt;/option&gt;
             ';
          break;
      case 1:
      echo '
          &lt;option value="opt1_1"&gt;Option1_Test1&lt;/option&gt;
          &lt;option value="opt1_2"&gt;Option1_Test2&lt;/option&gt;
          &lt;option value="opt1_3"&gt;Option1_Test3&lt;/option&gt;
         ';
          break;
      case 2:
      echo '
          &lt;option value="opt2_1"&gt;Option2_Test1&lt;/option&gt;
          &lt;option value="opt2_2"&gt;Option2_Test2&lt;/option&gt;
          &lt;option value="opt2_3"&gt;Option2_Test3&lt;/option&gt;
         ';
      break;
    }
   ?&gt;
  </code></pre>
  
  <p>I'm not massively conversant with Javascript so was wondering if it were possible to modify the javascript (the second chunk of code I can deal with myself I think) to do what is described below.</p>
  
  <p>Box 1 contains a row of images, serving as links, when one is clicked, a second box below these images is populated with more image links based on the selection from box 1 (information is grabbed from a database).</p>
  
  <p>I imagine from my limited understanding that I should be able to modify the 'onchange' js event to an onclick or whatever the equivalent is (can't remember off the top of my head) event inside an 'img' tag, or an 'a href' tag, again can't remember which right now.</p>
  
  <p>Hopefully someone will understand what I'm trying to do and make sense of it all :)</p>
  
  <p>Thanks
  TheMightySpud</p>