Jump to content

Simply populate location using php/ajax next to text field in my form?


sayedsohail

Recommended Posts

Hi everyone,

 

Sorry for this unusual question, so far i am able to query sql and display data using php ajax,

 

now i have got a scenario,

 

I got a text field (<input type='text' name='address'>) in my form which needs to be filled by the user. since I got addresses stored in database I thought to populate these addresses next to address field, than user can select from this new select populated address drop down or type his/her own address and the new dropdown should just close.

 

I am stuck, any advise would be greatly appreciated.

 

thanks for reading.

 

Link to comment
Share on other sites

sorry here is the code sample:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript">
function populate()
{
if (document.form1.select.value != "")
{
document.form1.textfield.value = document.form1.select.value;
}
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<p>
//****** This needs to be populated dynamically using php ajax from address table. ****///
<select name="select" onchange="populate();">
<option value="Roddy Dairion">Roddy</option>
<option value="Roders Dairion">Roddy1</option>
<option value="Rodstar Dairion">Roddy2</option>
<option value="Mr Dairion">Roddy3</option>
</select>
</p>
<p>
<input type="text" name="textfield" />
</p>
</form>
</body>
</html>

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.