如何通过jquery将变量的整数值添加到隐藏字段

时间:2017-11-03 14:11:15

标签: jquery

我希望将值function process_bulk_action() { if( 'approve'===$this->current_action() ) { $objCustomUserRoles = new CustomUserRoles(); if(!empty($_REQUEST['wp_premium_users_request'])) { foreach ($_REQUEST['wp_premium_users_request'] as $key => $value) { $objCustomUserRoles->updateCustomerToPremium($value); } add_action( 'admin_notices', 'my_update_notice'); } } } function my_update_notice() { ?> <div class="updated notice"> <p><?php _e( 'User approved!', 'avia_framework' ); ?></p> </div> <?php } 的返回值添加到隐藏字段var Selectedvalue中。

jQuery的:

id="Branchidhidden"

HTML:

function Branch() {
    var Selectedvalue =  $( "#Branchitemtypeid option:selected" ).val(); //The return value is correct 
    $('#Branchidhidden').attr('value', Selectedvalue)
}

当我看到隐藏字段中的view-source值为空时。

1 个答案:

答案 0 :(得分:1)

使用PROP / VAL代替ATTR

function Branch() {
    var Selectedvalue =  $( "#Branchitemtypeid option:selected" ).val(); //The return value is correct 
    $('#Branchidhidden').prop('value', Selectedvalue);

    // or val
    $('#Branchidhidden').val(Selectedvalue);
}