Jump to content

Anybody help with this form?


timmah1

Recommended Posts

I have a form, I'm only going to show a little part

 

I'm just starting to learn AJAX, and I'm getting stuck

<select name="plumbing" id="plumbing" onClick="plumbingUser(this.value)">
            <option></option>


    <option value="<?php echo $row['name']; ?>"><?php echo $row['name']; ?></option><br />

</select>
</td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td>HVAC Contractor</td>
    <td><table width="600" cellpadding="5" cellspacing="0">
        <tr>
          <td width="200">
            <div id="hvacHint"><b><?php echo $row9['hvac_contractor']; ?></b></div></td>

          <td width="200">
          <select name="hvac" id="hvac" onClick="hvacUser(this.value)">
          <option>--</option>
          <option value="an">Add New</option>
          <option>--</option>
    <option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option><br />

</select>

 

Here is the part that is suppose to bring out the values

var xmlHttp

function hvacUser(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getuser.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("hvacHint").innerHTML=xmlHttp.responseText 
} 
}

function plumbingUser(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getplumbing.php"
url=url+"?p="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById("plumbingHint").innerHTML=xmlHttp.responseText 
} 
}

 

The problem is, I think 'plumbingHint' is overriding the 'hvacHint' because where the hvac is suppose to show, nothing shows, but the hvac shows where plumbing is suppose to go, and nothing happens when I click on anything where the plumbing is.

 

Can anybody shed some light on what I'm doing wrong?

 

Thanks in advance

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.