如何将变量显示到文本输入中

时间:2013-01-19 23:51:24

标签: php javascript jquery

QandATable.php中的

我的下面有一个表单,其中包含文件输入和iframe:

var $fileVideo = $("<form action='videoupload.php' method='post' enctype='multipart/form-data' target='upload_target_video' onsubmit='return videoClickHandler(this);' class='videouploadform' >" + 
"Video File: <input name='fileVideo' type='file' class='fileVideo' /></label>" +  
"<input type='submit' name='submitVideoBtn' class='sbtnvideo' value='Upload' /></label>" + 
 "<p class='listVideo' align='left'></p>" +
"<iframe class='upload_target_video' name='upload_target_video' src='/' style='width:0px;height:0px;border:0px;solid;#fff;'></iframe></form>"); 

现在,我有一个jquery代码,在文件上传完成后会触发。

  function stopVideoUpload(success, videofilename){

      var result = '';
      videocounter++;

      if (success == 1){
         result = '<span class="videomsg'+videocounter+'">The file was uploaded successfully</span>';
          $('.listVideo').eq(window.lastUploadVideoIndex).append('<div>' + htmlEncode(videofilename));
      }


      return true;   
}

现在,文件上传的结果和文件名由下面的代码确定。但我的问题是如何在文本输入中显示$id变量?

 <script language="javascript" type="text/javascript">
 window.top.stopVideoUpload(<?php echo $result; ?>,'<?php echo $id . $_FILES['fileVideo']['name'] ?>');
 </script> 

1 个答案:

答案 0 :(得分:0)

我可能会误解您的问题,但如果您在输入字段中将type='text'更改为type='hidden',那么$ id变量将位于隐藏输入中。