2011-10-02 6 views
1

url의 끝에 검색어를 추가하는 사이트에 대한 검색 입력을 만들려고합니다. 양식을 검색하기 위해 검색어를 추가하여 URL을 검색하십시오.

문제의 URL입니다 :

http://apps.ticketbiscuit.com/ticketbiscuit.website/LyricTheatreOxford/Search/

문자열이 그들이 필요로하는 여러 단어가 포함되어있는 경우 수동으로 URL eg./Search/robert &의 끝 부분에 검색어를 추가하여 검색 할 수 있습니다

"% 20"eg./Search/Robert%20Earl로 구분됩니다.

http://apps.ticketbiscuit.com/ticketbiscuit.website/LyricTheatreOxford/Search/?s=Kevin&sitesearch=

내가 아는 내가 거기에 약간의 자바 스크립트를 필요 : I 입력에 케빈를 입력하면

<form method="get" action="http://apps.ticketbiscuit.com/ticketbiscuit.website/LyricTheatreOxford/Events/Search/" id="searchform" role="search"> 
    <input type="text" value="Search Events" name="s" id="s" onFocus="if (this.value == 'Search Events') {this.value=''; this.style.color='#000000';}"/> 
    <input type="hidden" name="sitesearch" value=""/> 
</form> 

는 양식이 URL을 반환 여기

내 현재 검색 양식입니다 검색을 처리하고 올바른 URL을 작성하려면 필요한 정보가 없습니다.

누구든지 아이디어가 있습니까? 이것이 다른 곳에서 답을 얻은다면 죄송합니다. 나는 주변을 둘러 보았지만 아무 것도 찾을 수 없었다.

답변

0

onsubmit="return searchForm(this)"을 양식 태그에 추가하십시오.

그런 다음, function searchForm를 정의도

<script> 
function searchForm(form){ 
    location.href = "http://apps.ticketbiscuit.com/ticketbiscuit.website/LyricTheatreOxford/Search/" + form.s.value; 
    return false; 
} 
</script> 

참조 : Open a URL based on search query without php "?q=(myTerm)" and instead with a simple "/(myTerm)"

+0

완벽하게 작동 ... 도움을 주셔서 너무 감사 – jrkellew

관련 문제