I am having trouble figuring out how to correctly execute the following problem. I have a web form that my user will fill out, this form has (ajax that populates the account user will work with aka admin).
我无法弄清楚如何正确执行以下问题。我有一个我的用户将填写的网络表单,此表单有(ajax填充帐户用户将使用aka管理员)。
Before submission of the new data I would like to verify if that account already has data, if data exists I need to have a confirmation to override the current data. If there is no data nothing happens (new data just gets inserted into the db).
在提交新数据之前,我想验证该帐户是否已有数据,如果数据存在,我需要确认覆盖当前数据。如果没有数据,则不会发生任何事情(新数据只会插入到数据库中)。
This is the flow of the page,
这是页面的流程,
1) (Ajax) Input -> Find account, 2) Once account selected enter data (no refresh between the two steps) 3) Submit data -> Still on same page (looking if Input Exists and executes Insert)
1)(Ajax)输入 - >查找帐户,2)选择帐户后输入数据(两步之间无刷新)3)提交数据 - >仍在同一页面上(查看输入是否存在并执行插入)
Is it possible to have some sort of confirmation inside the try / catch before submission.
是否有可能在提交前在try / catch中进行某种确认。
Code:
if(Input::exists()){
try{
if(row exists){
// Confirm here if row exists to override or cancel SUBMIT
}else{ // insert new }
Why I need this is because accounts are allowed to have only 1 of this kind of record, and I don't want them to accidentally override existing record (if it exists).
为什么我需要这个是因为允许帐户只有这种记录中的一种,我不希望它们不小心覆盖现有记录(如果存在)。
Thanks
1 个解决方案
#1
I have managed to solve it, what I did was onclick of account that would fill the INPUT BOX; I would than use ajax to check for the rows of selected account. If row was found I would ask for confirmation using jQuery confirm
and if clicked OK I would populate HIDDEN input with value 1
. So on submit it would check if the hidden field is 1 or 0 if 1 that would mean its an update of existing record and if 0 it would create new one.
我已经设法解决了这个问题,我所做的就是点击会填充INPUT BOX的帐户;我想使用ajax来检查所选帐户的行。如果找到了行,我会要求使用jQuery确认进行确认,如果单击确定,我会用值1填充HIDDEN输入。因此,在提交时,它将检查隐藏字段是1还是0如果为1则意味着它更新现有记录如果为0则会创建新的。
#1
I have managed to solve it, what I did was onclick of account that would fill the INPUT BOX; I would than use ajax to check for the rows of selected account. If row was found I would ask for confirmation using jQuery confirm
and if clicked OK I would populate HIDDEN input with value 1
. So on submit it would check if the hidden field is 1 or 0 if 1 that would mean its an update of existing record and if 0 it would create new one.
我已经设法解决了这个问题,我所做的就是点击会填充INPUT BOX的帐户;我想使用ajax来检查所选帐户的行。如果找到了行,我会要求使用jQuery确认进行确认,如果单击确定,我会用值1填充HIDDEN输入。因此,在提交时,它将检查隐藏字段是1还是0如果为1则意味着它更新现有记录如果为0则会创建新的。