gpt4 book ai didi

javascript - 保存信息后使用 jquery 隐藏按钮

转载 作者:行者123 更新时间:2023-11-30 17:34:48 26 4
gpt4 key购买 nike

我尝试在我的 prestashop 结帐页面中隐藏“保存”按钮。默认情况下, guest 字段时所有字段都需要点击“保存”按钮。奇怪但按钮不会消失。可能默认 js 中的某些东西不正常,但我不想碰它。我想用小 jquery 隐藏这个按钮。

您可以在以下网址实时查看:test.detelinmarkov.com/quick-order我尝试做的是:当信息正确且已保存客户看到消息“帐户信息保存成功”时,我尝试在显示此消息时隐藏“保存”按钮。

注意:在我尝试获取成功保存数据的一些 id 之前,因为如果客户返回其他页面或刷新结帐页面,“帐户信息已成功保存”消失,按钮会留在那里。

以及我尝试但不起作用的代码...

                {literal}
<script>
$('input[name=opc_account_saved]')
.click(
function ()
{
$(this).hide();

$("savebutton").hide();
}
);
</script>
{/literal}
<div id="savebutton">
<p class="submit">
<input type="submit" class="exclusive button" name="submitAccount" id="submitAccount" value="{l s='Save'}" />
</p>
</div>
<p style="display: none;" id="opc_account_saved">
{l s='Account information saved successfully'}
</p>

默认情况下按钮不消失的问题可能是在这个js中:

$(function() {
// GUEST CHECKOUT / NEW ACCOUNT MANAGEMENT
if ((!isLogged) || (isGuest))
{
if (guestCheckoutEnabled && !isLogged)
{
$('#opc_account_choice').show();
$('#opc_account_form, #opc_invoice_address').hide();

$('#opc_createAccount').click(function() {
$('.is_customer_param').show();
$('#opc_account_form').slideDown('slow');
$('#is_new_customer').val('1');
$('#opc_account_choice, #opc_invoice_address').hide();
updateState();
updateNeedIDNumber();
updateZipCode();
});
$('#opc_guestCheckout').click(function() {
$('.is_customer_param').hide();
$('#opc_account_form').slideDown('slow');
$('#is_new_customer').val('0');
$('#opc_account_choice, #opc_invoice_address').hide();
$('#new_account_title').html(txtInstantCheckout);
$('#submitAccount').prop({id : 'submitGuestAccount', name : 'submitGuestAccount'});
updateState();
updateNeedIDNumber();
updateZipCode();
});
}
else if (isGuest)
{
$('.is_customer_param').hide();
$('#opc_account_form').show('slow');
$('#is_new_customer').val('0');
$('#opc_account_choice, #opc_invoice_address').hide();
$('#new_account_title').html(txtInstantCheckout);
updateState();
updateNeedIDNumber();
updateZipCode();
}
else
{
$('#opc_account_choice').hide();
$('#is_new_customer').val('1');
$('.is_customer_param, #opc_account_form').show();
$('#opc_invoice_address').hide();
updateState();
updateNeedIDNumber();
updateZipCode();
}

// LOGIN FORM
$('#openLoginFormBlock').click(function() {
$('#openNewAccountBlock').show();
$(this).hide();
$('#login_form_content').slideDown('slow');
$('#new_account_form_content').slideUp('slow');
return false;
});
// LOGIN FORM SENDING
$('#SubmitLogin').click(function() {
$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: authenticationUrl + '?rand=' + new Date().getTime(),
async: false,
cache: false,
dataType : "json",
data: 'SubmitLogin=true&ajax=true&email='+encodeURIComponent($('#login_email').val())+'&passwd='+encodeURIComponent($('#login_passwd').val())+'&token=' + static_token ,
success: function(jsonData)
{
if (jsonData.hasError)
{
var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
for(var error in jsonData.errors)
//IE6 bug fix
if(error !== 'indexOf')
errors += '<li>'+jsonData.errors[error]+'</li>';
errors += '</ol>';
$('#opc_login_errors').html(errors).slideDown('slow');
}
else
{
// update token
static_token = jsonData.token;
updateNewAccountToAddressBlock();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
return false;
});

// INVOICE ADDRESS
$('#invoice_address').click(function() {
bindCheckbox();
});

// VALIDATION / CREATION AJAX
$('#submitAccount').click(function() {
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow')

var callingFile = '';
var params = '';

if (parseInt($('#opc_id_customer').val()) == 0)
{
callingFile = authenticationUrl;
params = 'submitAccount=true&';
}
else
{
callingFile = orderOpcUrl;
params = 'method=editCustomer&';
}

$('#opc_account_form input:visible, #opc_account_form input[type=hidden]').each(function() {
if ($(this).is('input[type=checkbox]'))
{
if ($(this).is(':checked'))
params += encodeURIComponent($(this).attr('name'))+'=1&';
}
else if ($(this).is('input[type=radio]'))
{
if ($(this).is(':checked'))
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
}
else
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
});
$('#opc_account_form select:visible').each(function() {
params += encodeURIComponent($(this).attr('name'))+'='+encodeURIComponent($(this).val())+'&';
});
params += 'customer_lastname='+encodeURIComponent($('#customer_lastname').val())+'&';
params += 'customer_firstname='+encodeURIComponent($('#customer_firstname').val())+'&';
params += 'alias='+encodeURIComponent($('#alias').val())+'&';
params += 'other='+encodeURIComponent($('#other').val())+'&';
params += 'is_new_customer='+encodeURIComponent($('#is_new_customer').val())+'&';
// Clean the last &
params = params.substr(0, params.length-1);

$.ajax({
type: 'POST',
headers: { "cache-control": "no-cache" },
url: callingFile + '?rand=' + new Date().getTime(),
async: false,
cache: false,
dataType : "json",
data: 'ajax=true&'+params+'&token=' + static_token ,
success: function(jsonData)
{
if (jsonData.hasError)
{
var tmp = '';
var i = 0;
for(var error in jsonData.errors)
//IE6 bug fix
if(error !== 'indexOf')
{
i = i+1;
tmp += '<li>'+jsonData.errors[error]+'</li>';
}
tmp += '</ol>';
var errors = '<b>'+txtThereis+' '+i+' '+txtErrors+':</b><ol>'+tmp;
$('#opc_account_errors').slideUp('fast', function(){
$(this).html(errors).slideDown('slow', function(){
$.scrollTo('#opc_account_errors', 800);
});
});
}
else
{
$('#opc_account_errors').slideUp('slow', function(){
$(this).html('');
});
}

isGuest = parseInt($('#is_new_customer').val()) == 1 ? 0 : 1;
// update addresses id
if(jsonData.id_address_delivery !== undefined && jsonData.id_address_delivery > 0)
$('#opc_id_address_delivery').val(jsonData.id_address_delivery);
if(jsonData.id_address_invoice !== undefined && jsonData.id_address_invoice > 0)
$('#opc_id_address_invoice').val(jsonData.id_address_invoice);

if (jsonData.id_customer !== undefined && jsonData.id_customer !== 0 && jsonData.isSaved)
{
// update token
static_token = jsonData.token;

// It's not a new customer
if ($('#opc_id_customer').val() !== '0')
if (!saveAddress('delivery'))
return false;

// update id_customer
$('#opc_id_customer').val(jsonData.id_customer);

if ($('#invoice_address:checked').length !== 0)
{
if (!saveAddress('invoice'))
return false;
}

// update id_customer
$('#opc_id_customer').val(jsonData.id_customer);

// force to refresh carrier list
if (isGuest)
{
isLogged = 1;
$('#opc_account_saved').fadeIn('slow');
$('#submitAccount').hide();
updateAddressSelection();
}
else
updateNewAccountToAddressBlock();
}
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow');
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to save account \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
$('#opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow')
}
});
return false;
});
}

bindCheckbox();
bindInputs();

$('#opc_account_form input,select,textarea').change(function() {
if ($(this).is(':visible'))
{
$('#opc_account_saved').fadeOut('slow');
$('#submitAccount').show();
}
});

});

最佳答案

id 选择器中缺少 #

$("#savebutton").hide();
//-^-----

关于javascript - 保存信息后使用 jquery 隐藏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22271862/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com