Although I'm not an expert in AJAX, Drupal, or Javascript, I'll do my best to articulate my question clearly.
Currently, I am working with Drupal 7 on MySQL in a dev environment. I've created my own module called 'acid' to manage custom autocomplete functions.
I'm in the process of developing a website for a company where they can input customer satisfaction forms for all their sites. In my database, I have tables named 'acid_company' and 'acid_sites', where one company can have multiple sites.
For adding a new site, users need to first enter the company name to check if it already exists in the DB. The autocomplete function for the company name field is functioning properly. However, I want to tweak the submit button functionality on the 'add company' form to redirect the user to the site addition form instead.
The envisioned steps are as follows:
- [user clicks 'add site'] -> [display 'add company' form] -> [validate user input in company_name autocomplete field]->
- If company already exists -> change form submit button to 'add site' (or provide a link to 'add site form')
- If company doesn't exist -> keep submit button unchanged -> user submits [add company and proceed to 'add site' form]
My query pertains to capturing events from the company_name element once a user has chosen a company name from the search results and adapting other components of the form accordingly.
Something like:
(user inputs company name) -> results found -> (user selects one of the results)<br />
<code>
do_disableForm()<br />
{<br />
this.form.addcompany.company_name.disable();<br />
this.form.addcompany.submit.disable();<br />
this.a.addsite.setVisable(TRUE);
}<br />
</code>
The "<a href='?q=addsite&companyid=xx'>add site</a>" link should also include the company ID in its hyperlink reference, possibly stored in a hidden form component.
Any assistance on this matter would be highly appreciated.
On a side note, I've attempted to adhere to the principles of 'the drupal way' throughout my work :)