2016-11-27 46 views
-1

http://localhost/check.php?date=textbox1&time=textbox2如何獲得使用HREF文本框的值沒有POST

<a href="http://localhost/check.php?date=textbox1&time=textbox2" onclick="window.open('http://localhost/check.php?date=textbox1&time=textbox2', 'newwindow', 'width=600, height=600'); return false;"> <i class="glyphicon glyphicon-plus"></i></a> 

這是我當前的代碼,我想在一個GET方法傳遞文本框1和文本2的值。我試過document.getElementbyId('date')。價值,但沒有運氣。

+2

您的問題似乎並不清楚,請詳細說明更多的代碼的! –

+0

@SaumyaRastogi我認爲他正在嘗試通過手動將文本框值傳遞到URL來創建動態超鏈接,而不是使用表單。基本上,他試圖在提交之前將值從文本框中提取出來。雖然他的代碼沒有意義,如果這是他正在嘗試..我看到你的觀點,大聲笑 – icecub

+0

嗨,大家好。我有2個文本框(日期,時間)我想在點擊href鏈接時將它們的值傳遞給我的鏈接。 *按鈕點擊傳輸到http://localhost/check.php?date = textbox1value&time = textbox2value謝謝。 – Aaron

回答

0

我不知道你在這裏試圖做什麼。據我瞭解, 你有這樣的...:

<input type="text" id="date"/> 
<input type="text" id="time"/> 

...你想用這些文本框值請求參數。試試這個:

function submitDateAndTime() { 
    var url = 'http://localhost/check.php?date='; 
    url += document.getElementById('date').value; 
    url +='&time='; 
    url += document.getElementById('time').value; 
    // Do whatever you want with the URL here 
    // For example, window.open to load in a new window: 
    window.open('url'); 
    // Or use _self if you want to load in the current window 
    window.open('url', '_self'); 
    // Or ajax, etc. 

和HTML:

<a href="javascript:void submitDateAndTime();">Submit</a> 
+0

非常感謝! – Aaron

相關問題