[英]How To - Button to change a dropdown value?
我想問一下如何使按鈕更改字段的值。
如上圖所示,下拉菜單狀態應從“未付費”更改為“已付費”。 人們從制糖社區告訴我,是要更改元數據。 我嘗試過,但是在調用該字段並更改其值時遇到了麻煩。 我所知道的是,我的“狀態”字段是LBL_Quote_Stage。
請問任何可能的解決方案? 另外,這是我的模塊“ UA_Quotes”的元數據代碼
<?php
$module_name = 'UA_Quotes';
$viewdefs [$module_name] =
array (
'DetailView' =>
array (
'templateMeta' =>
array (
'form' =>
array (
'closeFormBeforeCustomButtons' => true,
'buttons' =>
array (
0 => 'EDIT',
1 => 'DELETE',
2 =>
array (
'customCode' => '<input id="MonthlyQuote" title="Monthly Quote" class="button" type="button"
name="Quote Payment" value="Quote Payment" onclick="alert(\'How to change status :(\')">',
),
),
'footerTpl' => 'modules/UA_Quotes/tpls/DetailViewFooter.tpl',
),
'maxColumns' => '2',
'widths' =>
array (
0 =>
array (
'label' => '10',
'field' => '30',
),
1 =>
array (
'label' => '10',
'field' => '30',
),
),
'useTabs' => false,
'tabDefs' =>
array (
'LBL_EDITVIEW_PANEL2' =>
array (
'newTab' => false,
'panelDefault' => 'expanded',
),
),
),
'panels' =>
array (
'lbl_editview_panel2' =>
array (
0 =>
array (
0 => 'name',
1 =>
array (
'name' => 'ua_contracts_ua_quotes_1_name',
),
),
1 =>
array (
0 =>
array (
'name' => 'monthlystart_c',
'label' => 'LBL_MONTHLYSTART',
),
1 =>
array (
'name' => 'quote_stage',
'studio' => 'visible',
'label' => 'LBL_QUOTE_STAGE',
),
),
2 =>
array (
0 =>
array (
'name' => 'monthlydeadline_c',
'label' => 'LBL_MONTHLYDEADLINE',
),
),
),
),
),
);
?>
我使用的是sugarCE 6.5,謝謝大家! :(
您必須點擊“報價支付”按鈕進行ajax調用。
var record = $("#record").val(); // value of record which you can see in var fdata = { 'record':record }; $.ajax({ url: "ajaxFiles/addPayment.php?&fdata="+fdata+"", type: 'POST', data: fdata, dataType: 'html', async: false, error: function(resp){}, success: function(resp){ //refresh the page } });
root/ajaxFiles/addPayment.php
文件夾中創建addPayment.php
include("../config.php"); $localhost = $sugar_config['dbconfig']['db_host_name']; $user = $sugar_config['dbconfig']['db_user_name']; $password = $sugar_config['dbconfig']['db_password']; $db_name = $sugar_config['dbconfig']['db_name']; $recordId= $_POST['record']; //write a query to update the status of the field
希望這能解決您的問題。 謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.