Link to home
Start Free TrialLog in
Avatar of aej1973
aej1973

asked on

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
Avatar of Joe Wu
Joe Wu
Flag of Australia image

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>
include autopostback="True"
Avatar of aej1973
aej1973

ASKER

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.
I think you would still use the onchange property, it still applies for text boxes as well, same syntax as above.
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?
Avatar of aej1973

ASKER

php
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
Avatar of aej1973

ASKER

ha, ha. Thanks, I will try this change in a little while.
Avatar of aej1973

ASKER

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>
if you just use an alert or something for the onchange does it work?
Avatar of aej1973

ASKER

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>
ASKER CERTIFIED SOLUTION
Avatar of lunadl
lunadl
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aej1973

ASKER

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin