How to pass single page value to controller through script
Permalink 1 user found helpful
Hi
In my application list out the employee role by using for each
single page:
JS
to edit the role i use the href link to pass the value to controller but in the case delete, i want conformation from user so i use button_js call the script and validate it but i dnt know how to pass the corresponding value(role_id) to controller ?
help please:-)
thanks
Kumar
In my application list out the employee role by using for each
single page:
foreach($rd as $data){ echo "<tr><td>".$data[role_name]."</td><td>".$data[role_description]."</td><td><a href=".$this->action('edit', $data['role_id']).">Edit</a></td><td>".$ih->button_js(t('Delete'), "deleteRole()", 'left', 'error')."</td></tr>"; }
JS
to edit the role i use the href link to pass the value to controller but in the case delete, i want conformation from user so i use button_js call the script and validate it but i dnt know how to pass the corresponding value(role_id) to controller ?
help please:-)
thanks
Kumar
Also in your form, include a token to verify that the post is genuine:
http://www.concrete5.org/documentation/how-tos/developers/use-token...
http://www.concrete5.org/documentation/how-tos/developers/use-token...
thanks for reply, i have small query i am using ajax to pass the value but my query how to full url in concrete.
in this code write in single page how to call the corresponding controller page? Its right or wrong?
thanks
Kumar
in this code write in single page how to call the corresponding controller page? Its right or wrong?
$.ajax({ type: 'post', data: { myvar: myvar }, url: "<?php echo $this->url('/role/add_role/', 'delete', 'data')?>", });
thanks
Kumar
Then the controller method looks like this: