question regarding ajax suggest ...

I have a ajax auto complete form. I am using the example from the following site:
http://www.brandspankingnew.net/specials/ajax_autosuggest/ajax_autosuggest_autocomplete.html
Insted of the array they have used in the example I have connected  a datebase using php. The application is set up in such a way that once I make the selection I need to press the submit button to have the output passed to the next page. BUT I need to out to be passed as soon as a selection is make without having to press the select button. How do I do this? Thank you for the help.

A
aej1973Asked:
Who is Participating?
 
lunadlCommented:
something like this...
<form name="somename"action="#" method="get">
....<input style="width: 200px" type="text" id="testinput" value=""  onChange="dopb()"/>
</form>
function dopb()
{
document.somename.submit();
}
0
 
nizsmoDeveloperCommented:
Do you mean without having to press the submit button (instead of select button?). You can do this by using the onchange event property for the selction box, so that when the selection has changes, it will automatically call some function (the same as what your submit button does):
Something like this:

<select onchange="callMyFunction();" ....>
// options here
</selec>
0
 
lunadlCommented:
include autopostback="True"
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
aej1973Author Commented:
for example take a look at this site:
http://lyricsfly.com/search/search.php

I do not have to use the search button.

Lunadl: where do I need to insert 'autopostback' ?
Nizsmo: this is a text box not a menu list.

Thanks for getting back to me.
0
 
nizsmoDeveloperCommented:
I think you would still use the onchange property, it still applies for text boxes as well, same syntax as above.
0
 
lunadlCommented:
oh you wouldn't even need autopostback.. what type of control is your 'hidden field'? If it is html you can put a postback ontextchange or if its an asp control you can add ontextchange with autopostback enabled.. what platform are you using?
0
 
aej1973Author Commented:
php
0
 
lunadlCommented:
shoot me i'm confused.. i was doing .net all day today.. didn't even read your question completely i guess. PHP. you want to do a postback on text change for your hidden field
0
 
aej1973Author Commented:
ha, ha. Thanks, I will try this change in a little while.
0
 
aej1973Author Commented:
It does not seem to be working. My code is as follows:

<form method="post" action="subscriber_details.php">
      <label for="testinput_1_xml"><span class="style1">Account# </span></label>
      <p>
        <input type="text" id="testinput_1_xml" style="width:300px"  name="D1"  onChange="subscriber_details.php"/>
        <br />
        <br />
        <input type="submit" value="submit" />
</p>
      <p>&nbsp;    </p>
</form>
</div>



<h2>&nbsp;</h2>

<h3>&nbsp;</h3>

</div>
</div>


<script type="text/javascript">
      var options = {
            script:"test.php?json=true&",
            varname:"input",
            json:true,
            callback: function (obj) { document.getElementById('testid').value = obj.id; }
      };
      var as_json = new AutoSuggest('testinput', options);
      
      
      var options_xml = {
            script:"test.php?",
            varname:"input"
      };
      var as_xml = new AutoSuggest('testinput_xml', options_xml);
</script>

<script type="text/javascript">
      var options = {
            script:"test_1.php?json=true&",
            varname:"input",
            json:true,
            callback: function (obj) { document.getElementById('testid').value = obj.id; }
      };
      var as_json = new AutoSuggest('testinput_1', options);
      
      
      var options_xml = {
            script:"test_1.php?",
            varname:"input"
      };
      var as_xml = new AutoSuggest('testinput_1_xml', options_xml);
</script>
0
 
lunadlCommented:
if you just use an alert or something for the onchange does it work?
0
 
aej1973Author Commented:
Hi Lunadl, yes the alert works.

<form method="post" action="">
      <small style="float:right"><input type="text" id="testid"    name="D1" readonly="1"/></small>
      <label for="testinput">Subscriber Name </label>
      <input style="width: 200px" type="text" id="testinput" value=""  onChange="alert()"/>
      <input type="submit" value="submit" />
</form>
0
 
aej1973Author Commented:
Hello Lunadl, sorry for the delay in getting back to you. I tried this code, what happens is that I am redirected to the next page ''onChange' but the value is not being passed (in this case 'D1')
<!--===========MY CODE======================-->
<form method="get" action="subscriber_details.php" name="subscriber">
<label for="testinput">Subscriber Name </label>
      
 <input style="width: 200px" type="text" id="testinput" />  // This field is the auto suggest field        for the subscriber name
  <input type="hidden" id="testid"   value=""  readonly="1" name="D1" onChange="dopb()"/> //hidden field that has the account# of the subscriber. Account# needs to be passed to the next form.
</form>
<!--=====================java scirpt you had suggested==============-->
<script language="javascript">
function dopb()
{
document.subscriber.submit();
}</script>

Any suggestions? Thank you.

A
0
 
nizsmoDeveloperCommented:
Your value D1 has no values to be passed, since it is hidden, and you did not assign a value to it. Also if D1 is hidden and readonly how are you able to call the onChange event??

Something like this printed out "testing" on the php page for me:


<form method="get" action="test.php" name="subscriber">
<label for="testinput">Subscriber Name </label>
     
 <input style="width: 200px" type="text" id="testinput" onChange="dopb();"/>
  <input type="hidden" id="testid"   value="testing"  readonly="1" name="D1"/>
</form>
<!--=====================java scirpt you had suggested==============-->
<script language="javascript">
function dopb()
{
document.subscriber.submit();
}</script>


with PHP script:
<?php
echo $_REQUEST["D1"];
?>

Hope this helps.
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.