2012-02-09 64 views
1

我有一個文本框,當我在該文本框中寫入內容時,如果按Tab鍵,則警告將作爲「請稍候」,然後我想顯示在該jsp頁面或不同的jsp頁面中輸入值,該警報即將到來,但輸入的文本框值不顯示,該怎麼辦?在按TAB鍵的相同/不同頁面上顯示文本框的值

// a.jsp

<script type="text/javascript"> 
var obj; 
    var TAB = 9; 
    function catchTAB(evt,elem) 
    { 
    obj = elem; 
    var keyCode; 
    if ("which" in evt) 
    {// NN4 & FF &amp; Opera 
    keyCode=evt.which; 
    } else if ("keyCode" in evt) 
    {// Safari & IE4+ 
    keyCode=evt.keyCode; 
} else if ("keyCode" in window.event) 
{// IE4+ 
keyCode=window.event.keyCode; 
} else if ("which" in window.event) 
{ 
keyCode=evt.which; 
} else { alert("the browser don't support"); } 

if (keyCode == TAB) 
{ 
obj.value = obj.value + "\t"; 
alert("Please wait"); 
setTimeout("obj.focus()",1);// the focus is set back to the text input 
} 
} 
</script> 
<body> 
<input type="text" name="textboxname" onkeydown="catchTAB(event,this);"/>// after hitting TAB key i want to see that entered value in a.jsp page, how can i do it? 
</body> 

任何幫助

+0

你能說清楚你在做什麼嗎?您是否想要在警報消息中顯示文本輸入值? – 2012-02-09 18:26:55

回答

0

既然你是能夠趕上標籤的事件,它是那麼很容易得到來自該事件的價值,任何地點進行填充在該頁面中。

 <script type="text/javascript"> 
var obj; 
    var TAB = 9; 
    function catchTAB(evt,elem) 
    { 
    obj = elem; 
    var keyCode; 
    if ("which" in evt) 
    {// NN4 & FF &amp; Opera 
    keyCode=evt.which; 
    } else if ("keyCode" in evt) 
    {// Safari & IE4+ 
    keyCode=evt.keyCode; 
} else if ("keyCode" in window.event) 
{// IE4+ 
keyCode=window.event.keyCode; 
} else if ("which" in window.event) 
{ 
keyCode=evt.which; 
} else { alert("the browser don't support"); } 

if (keyCode == TAB) 
{ 
obj.value = obj.value + "\t"; 
alert("Please wait"); 
alert(obj.value); 
document.getElementById('textboxNew').value = obj.value; 
setTimeout("obj.focus()",1);// the focus is set back to the text input 
} 
} 
</script> 
<body> 
<input type="text" name="textboxname" onkeydown="catchTAB(event,this);"/>// after hitting TAB key i want to see that entered 

value in a.jsp page, how can i do it? 

<input type="text" name="textboxNew" id="textboxNew"/> 
</body> 
相關問題