开发者

Using Ajax with cakephp

开发者 https://www.devze.com 2022-12-26 00:19 出处:网络
HI I am new to cakephp so any help would be grateful. I have created a form and with one of the fields when the user has filled in checks to see it it already exists and offers other suggestions.开发者

HI I am new to cakephp so any help would be grateful. I have created a form and with one of the fields when the user has filled in checks to see it it already exists and offers other suggestions.开发者_如何学Go I have used the Ajax observerField method to do this. I want the user to be able to click on the suggested names(radioboxes) and then it update the field in the other form. What is the best way to achieve this in cakephp?


If it was me, I would create a form field

echo $form->input('otherfield');

Then use javascript to catch the click on the suggested radio, and copy the value into that field.

In jQuery,

$('#suggestions input[type=radio]').click(function(){
  $('#otherfield').val() = $(this).val();
});

Then when the form is submitted you will have it in,

$this->data['Model']['otherfield']
0

精彩评论

暂无评论...
验证码 换一张
取 消