0
私のウェブサイトの1つは、国、州、市の自動応募のためのhttp://digitarald.de/project/autocompleter/プラグインです。Mootools Autosuggestion Customization
例: 州には検索テキストや国コードのような2つの入力が必要です。複数の引数を渡すため
'postVar' : 'text',
'postData':{'country':$('country'.get('value'))},
を使用して上記のプラグインのドキュメントから
。
ここで$('country')
は、最初の提案から国コードを設定します。今は問題は私が入力としてcountry
を送ることができないためです。そのセットは動的なjavascript呼び出しからです。どのように問題を解決する。
var countryAutocomplete = new Autocompleter.Request.JSON('countrySearch', 'www.example.com/country', {
'postVar' : 'text',
'minLength': 1,
'injectChoice': function(areas){
var choice = new Element('li', {'class': 'autocompleter-choices1', 'id':areas.label});
new Element('div', {'html': this.markQueryValue(areas.label),'class': 'autocompleter-choice1'}).inject(choice);
this.addChoiceEvents(choice).inject(this.choices);
choice.store('autocompleteChoice', areas);
}
});
//set the selected value in a hidden field
countryAutocomplete.addEvent('onSelection', function(element, selected, value, input) {
$('country').value = country = selected.retrieve('autocompleteChoice').id;
});
// suggets states
var stateAutocomplete = new Autocompleter.Request.JSON('stateTxt', 'www.example.com/state', {
'postVar' : 'text',
'postData':{'postData':{'country':$('country'.get('value'))},},
'minLength': 3,
'injectChoice': function(areas){
var choice = new Element('li', {'class': 'autocompleter-choices1', 'id':areas.label});
new Element('div', {'html': this.markQueryValue(areas.label),'class': 'autocompleter-choice1'}).inject(choice);
this.addChoiceEvents(choice).inject(this.choices);
choice.store('autocompleteChoice', areas);
}
});
任意の助けを感謝します、次のように
をしようとしました。おかげ
あなたのお返事ありがとうございます:) – abhis