2013-02-25 82 views
0

嗨,我工作的表單上調用一個攝像頭插件到目前爲止一切工作正常,但我想顯示對齊我的表格內的攝像頭屏幕 我希望攝像頭輸出顯示在具有ID「凸輪」的div。誰能幫我請document.writehtml裏面的一個div

這裏是我的javascript

<script> 
document.getElementById("cam").innerHTML = document.write(webcam.get_html(320, 420)); 
</script> 

這裏是我的html

<body bgcolor="Darkgrey"> 
    <form name="entry" method="POST" action="" id="entry"> 
    <table border="1" bgcolor="Silver"> 
     <tr> 
      <td> 

      </td> 
      <td> 
       <h2><b>Candidate Entry</b><h2> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       Code 
      </td> 
      <td> 
      <input type="text" name="vouchno" value="New" onkeypress="return isNumberKey(event)" readonly="readonly" size="8" maxlength="8"> 
      Date 
      <input type="text" name="vouchdt" id="popupDatepicker" tabindex="1"></td> 
     <td> 
      <input type="text" name="councode" size="1" maxlength="2"><input type="text" name="counvouch" size="8" maxlength="8"> 
     </td> 
     <td><div id="cam"> 
        <input type=button value="Configure..." onClick="webcam.configure()"> 
     &nbsp;&nbsp; 
     <input type=button value="Take Snapshot" onClick="take_snapshot()"> 
      <div id="upload_results" style="background-color:#eee;"></div> 
      </div> 

     </td> 
     </tr> 
     <tr> 
      <td> 
       Name 
      </td> 
      <td> 
       <input type="text" name="name" value="" maxlength="40" size="45" tabindex="2"> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       Address 
      </td> 
      <td> 
       <textarea name="add" row="3" cols="40" tabindex="3"> 
       </textarea> 
      </td> 
     </tr> 

     <tr> 
      <td> 
       City 
      </td> 
      <td> 
       <input type="text" name="city" size="20" maxlength="20"value="" tabindex="4"> 
      Pin 
       <input type="text" name="pin" size="6" maxlength="6"value="" tabindex="5"> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       Nationality 
      </td> 
      <td> 
       <input type="text" name="ntn" value="" size="10" maxlength="10" tabindex="6"> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       Mobile No 
      </td> 
      <td> 
       <input type="text" name="mob" value="" tabindex="7"> 
      </td> 
     </tr> 
      <tr> 
       <td> 
        Date of Birth 
       </td> 
       <td> 
        <input type="text" name="dob" id="popupDatepicker2" tabindex="8"> 
       </td> 
       <td> 
        Age 
       </td> 
       <td width="9px"> 
        <input type="text" name="age" size="3" maxlength="3" value="" tabindex="9"> 
       </td> 
       <td width="10px"> 
        Sex 
       </td> 
       <td> 
          <select name="sex" tabindex="12"> 
          <option value="m">Male</option> 
          <option value="f">Female</option>       
          </select>     

       </td> 
      </tr> 
       <tr> 
        <td> 
         Religion 
        </td> 
        <td> 
         <input type="text" name="rel" value="" size="20" maxlength="20" tabindex="11"> 

        </td> 
        <td> 
         Martial Status 
        </td> 
        <td> 
         <select name="status" tabindex="12"> 
          <option value="">--select--</option> 
          <option value="1">Married</option> 
          <option value="2">Unmarried</option>       
          </select> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         Passport No. 
        </td> 
        <td> 
         <input type="text" name="pass" value="" size="15" maxlength="15" tabindex="13"> 
        </td> 
        <td> 
         Place of Issue 
        </td> 
        <td> 
         <input type="text" name="poi" size="20" maxlenght-20 tabindex="14"> 
        </td> 
        <td> 
         Date of Issue 
        </td> 
        <td> 
         <input type="text" name="doi" id="popupDatepicker4" tabindex="15"> 

        </td> 
       </tr> 
        <tr> 
         <td> 
          Profession 
         </td> 
         <td> 
         <input type="text" name="prof" size="20" maxlenght="20" value="" tabindex="16"> 
         </td> 
         <td> 
          Amount 
         </td> 
         <td> 
          <input type="text" id="amt" name="amt" value="" onblur="calculateText()" tabindex="17"> 
         </td>            
        </tr> 
        <tr> 
         <td> 
          Payment 
         </td> 
         <td> 
          <input type="text" id="pay" name="pay" value="" tabindex="20" > 
         </td> 
         <td> 
          Received 
         </td> 
         <td> 
          <input type="text" id="resc" name="resc" value="" onblur="calculateText()" tabindex="18"> 
         </td> 
        </tr> 
        <tr> 
        <td> 
         Agent 
        </td> 
        <td> 
         <input type="tetx" name="agnt" value="" size="40" maxlength="40" tabindex="21"> 
        </td> 
        <td> 
         Balance 
        </td> 
        <td> 
         <input type="text" id="bal" name="bal" readonly="readonly" value="" onblur="calculateText()" tabindex="19"> 
        </td> 
        </tr> 
        <tr> 
         <td> 
          Mofa No. 
         </td> 
         <td> 
          <input type="text" name="mofa" value="" size="20" maxlength="20" tabindex="22"> 
         </td> 
        </tr> 
        <tr> 
         <td> 
          Remarks 
         </td> 
         <td> 
          <input type="text" name="rem" size="60" maxlength="60" value="" tabindex="23"> 
         </td> 
        </tr> 
        <table border="0" align="center"> 
         <tr> 

          <td> 
           <input type="submit" name="save" value="Save"> 

          <td> 
           <input type="submit" name="print" value="Print"> 
          </td> 
          <td> 
           <input type="submit" name="close" value="Cancel"> 
          </td> 
         </tr> 
        </table> 
    </table>  
    </form> 
</body> 
</html> 
+0

嘗試使用jquery ... VAR webcamHTML = webcam.get_html(320 ,420); $('#cam')。append(webcamHTML); – SKT 2013-02-25 11:12:49

+0

即使dts不工作 – kumail 2013-02-25 11:29:39

回答

1

document.write寫入內容的文件,所以更改:

document.getElementById("cam").innerHTML = document.write(webcam.get_html(320, 420)); 

document.getElementById("cam").innerHTML = webcam.get_html(320, 420); 
+0

我試過但dts不工作 – kumail 2013-02-25 11:27:05

+0

@kumail做你的webcam.get_html();給你適當的內容......? – 2013-02-25 11:28:20

+0

是的,但它的框架沒有進入邊界 – kumail 2013-02-25 11:38:43

0

變化:

document.getElementById("cam").innerHTML = document.write(webcam.get_html(320, 420));

到:

document.getElementById("cam").innerHTML = webcam.get_html(320, 420);

編號:http://www.w3schools.com/jsref/prop_html_innerhtml.asp

+0

我試着用它按鈕點擊,但它不工作 – kumail 2013-02-25 11:36:27