我可以回显输入类型ID吗?

时间:2014-03-20 10:42:50

标签: jquery html ajax

我想从此输入(idstatus)类型回显输入id:

<input type="text" name="id" id="idstatus" class="text ui-widget-content ui-corner-all">

在js中我调用事件ID:

var testing = (calEvent.idEvent);
$("#idstatus").val(testing);

是否可以回显calEvent.idEvent?

完整代码:

agenda_view.php(我想让idstatus得到回应):

<div id="dialogstatusevent" style="display:none" title="Mijn Afspraak">
<form>
<div class="control-group" >
    <label class="control-label">Id:</label>
    <div class="controls">  
        <input type="text" name="id" id="idstatus" class="text ui-widget-content ui-corner-all">
    </div>
</div> 

fullcalendarextern.js:

eventClick: function(calEvent, jsEvent, view) {
    $( "#dialogstatusevent" ).dialog({
        autoOpen: false,
        height: 'auto',
        width: 'auto',
        modal: true,
        closeOnEscape:true, 
        resizable:false, 
        show:'fade',
        buttons: { 
            "Edit": function() {
                var id = $("#idstatus").val(),
                werknemerstatus = $("#werknemerstatus").val(),
                projectstatus = $("#projectstatus").val(),
                klantstatus = $("#klantstatus").val(),
                taakstatus = $("#taakstatus").val(),
                titlestatus = $("#titlestatus").val(),
                descstatus = $("#descstatus").val(),
                startdatestatus = $("#startdatestatus").val(),
                starttimestatus = $("#starttimestatus").val(),
                startstatus = startdatestatus + starttimestatus,
                enddatestatus = $("#enddatestatus").val();
                endtimestatus = $("#endtimestatus").val();
                endstatus = enddatestatus + endtimestatus,
                kleurstatus = $("#kleurstatus").val();

                if(startdatestatus=='' || enddatestatus=='') {
                    //alert("Please do not empty....!",title="Hello");
                    $("#d2").dialog("open");
                    $("#d2").dialog({
                        buttons:{
                            "OK":function(){
                                $(this).dialog("close");
                                $("#id:first").focus(); 
                            }
                        }
                    }); 
                    exit;
                }//End if statement


                $.post('../testcalendar/db/processupdate.php',{
                    id: id, idWerknemer: werknemerstatus, idProject: projectstatus, idKlant: klantstatus, idTaak: taakstatus, title: titlestatus, description: descstatus, start: startstatus, startdate: startdatestatus, starttime: starttimestatus, end: endstatus, enddate: enddatestatus,endtime: endtimestatus, color: kleurstatus, action:'joined'
                });
                var nTime = 1 * 50;
                window.setTimeout("location.reload()", nTime);
                $("#idstatus").val('');
                $("#werknemerstatus").val('');
                $("#projectstatus").val('');
                $("#klantstatus").val('');
                $("#taakstatus").val('');
                $("#titlestatus").val('');
                $("#descstatus").val('');   
                $("#startdatestatus").val('');  
                $("#starttimestatus").val('');  
                $("#enddatestatus").val('');    
                $("#endtimestatus").val('');    
                $("#kleurstatus").val('');  
                $(this).dialog("close");
            }, 
            "Cancel": function() { 
                $("#idstatus").val('');
                $("#werknemerstatus").val('');
                $("#projectstatus").val('');
                $("#klantstatus").val('');
                $("#taakstatus").val('');
                $("#titlestatus").val('');
                $("#descstatus").val('');
                $("#startdatestatus").val('');
                $("#starttimestatus").val('');
                $("#enddatestatus").val('');
                $("#endtimestatus").val('');
                $("#kleurstatus").val('');
                $(this).dialog("close"); 
                } 

            }
        }

    );
    var testing = (calEvent.idEvent);
    $("#idstatus").val(testing),
    $("#werknemerstatus").val(calEvent.idWerknemer),
    $("#projectstatus").val(calEvent.idProject),
    $("#klantstatus").val(calEvent.idKlant),
    $("#taakstatus").val(calEvent.idTaak),
    $("#titlestatus").val(calEvent.title),
    $("#descstatus").val(calEvent.description),
    $("#startdatestatus").val(calEvent.startdate),
    $("#starttimestatus").val(calEvent.starttime),
    $("#enddatestatus").val(calEvent.enddate),
    $("#endtimestatus").val(calEvent.endtime),
    $("#kleurstatus").val(calEvent.color);
    $("#startdatestatus").datepicker({ dateFormat: 'yy-mm-dd' });
    $("#enddatestatus").datepicker({ dateFormat: 'yy-mm-dd' });
    $( "#dialogstatusevent" ).dialog( "open" );
},

Processupdate.php(与问题无关但可能需要修改):

1 个答案:

答案 0 :(得分:0)

试试这个:

$('#idstatus').val($(this).id);

或者这个:

$('#idstatus').val($(this).attr('id'));