Amruta
Amruta

Reputation: 41

Special charactes in query parameter

I am using 1 search option on my form. Here when i pass any special characters like & or $ it does not hold that request parameter in the search box yeah but it is processing my request of search.

Upvotes: 1

Views: 1881

Answers (2)

xRadio.us
xRadio.us

Reputation: 85

I don't know Java but I used code similar to that below when sending user text to Google translate via Google URL parameter. (Assume values for myText, myURL, and myTextURL are already assigned.)

<script>
function transfix(isURL,form) {
    if(isURL) window.open( myURL     + encodeURIComponent(myText) );
    else      window.open( myTextURL + decodeURIComponent(myText) );  
}
</script>

<form target=_blank id="translate" name="translate">

<input type="button" value="Text" onclick="transfix(false,this.form)">
<input type="button" value="URL"  onclick="transfix(true,this.form)"> 

</form>  

Upvotes: 0

Rich O&#39;Kelly
Rich O&#39;Kelly

Reputation: 41767

You need to URL encode the values in the query string.

Upvotes: 2

Related Questions