2017-04-07 2 views
0

私は入力フィールドとボタンがあります。入力フィールドには読み込み時に値がありますが、ページが読み込まれた後にその値を変更したい場合は、クリックして新しいタブのURLとして値を使用します。私はjavascriptには何か助けになる新しいです。前もって感謝します。新しいタブで入力フィールドの値を開きます。私はリアルタイムで入力フィールドの値を変更したいです

<table width="100%" border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
    <td> 
    <input type="text" id="box" value="http://google.com" width="100%" /> 
</td> 
    <td> 
    <button id="newtab1" value = "Search" style="position: absolute;">New Tab</button> 
    </td> 
    </tr> 
</table> 
+0

を持っています。 – freginold

+0

[ask]をお読みください。重要なフレーズ:「検索と研究」と「あなたがそれを自分で解決することを妨げた困難を説明する」 –

答えて

0

ボタンにonclickプロパティを追加します。

<button id="newtab1" value = "Search" style="position: absolute;" onclick="MyFunction();">New Tab</button> 

次にあなたが既に試したどのようなコードを示している場合、我々はあなたがそれを改善することができ、あなたの関数のプロセス入力

<script> 
function MyFunction(){ 
    var url = document.getElementById('box').value 
    window.open(url); 
} 
</script> 
+0

何も起こっていません – RittenRA

+0

console.logをwindow.openに変更しなければならなかったのですが...あなたの方向性に感謝します – RittenRA

0
document.onload=function(){ 
var url ="your url " 
document.getElementById("box").value=url; 
} 
function myFunction(){ 
Window.open(document.getElementById("box"); 
} 
<button id="newtab1" value = "Search" style="position: absolute;" onclick="myFunction();">New Tab</button> 
関連する問題