嗨,感謝您的幫助!當您點擊輸入時,圖片標記onclick事件不起作用
我目前在SharePoint 2010中工作。我有一個搜索框使用圖像onclick()事件來觸發搜索。單擊圖像圖標時效果很好,但在文本框中單擊輸入一次時完全不起作用。這是按鈕的代碼。
<div style="position:relative; top:-3px; ">
<label for="Search"><b>SEARCH</b>
</label>
<label for="Content">
<input id="Content" type="radio" name="radiou" value="URL" checked="checked" style="margin-bottom:5px" />Content</label>
<label for="Employees">
<input id="Employee" type="radio" name="radiou" value="URL" style="margin-bottom:5px" />Employee</label>
<input id="search_txt" title="Enter search words" type="text" name="k" maxlength="80" size="25" />
<img src="/Style Library/Images/Search_button.png" onclick="submitSearch()" alt="Search Button" style="margin:0px; position:relative; top:7px; width:30px;"></img>
</div>
這裏是激活按鈕點擊代碼的JavaScript。我想在輸入一個詞並點擊Enter鍵後也會被解僱。
< script type = "text/javascript"
language = "JavaScript" >
// <![CDATA[
function submitSearch() {
var radiovals = document.getElementsByName("radiou");
var hostnameforsearch = window.location.hostname;
if (radiovals[0].checked) {
queryVal = $('#search_txt').val();
var searchUrl = 'http://' + hostnameforsearch + '/search/results.aspx?k=' + queryVal + '&u=' + hostnameforsearch + '&cs=This Site';
window.location = searchUrl;
return false;
} else {
queryVal = $('#search_txt').val();
window.open('http://search.URL.com/Pages/PeopleResults.aspx?k=' + queryVal);
};
}; // ]]>
< /script>
感謝所有幫助! 肯
所以,你真正想要的是調用submitSearch()當用戶按下TE輸入輸入? –
感謝您回覆路易斯....是的...用戶在搜索文本框中輸入內容,然後點擊輸入並執行搜索。由於嵌套的表單問題,我無法使用表單標記。 –
或者你想想。你爲什麼不能有兩種形式? – mplungjan