Pol Posted February 10, 2015 Share Posted February 10, 2015 Hello People! The charset=UTF-8 is not affecting the search form when using JavaScript and radio buttons.Arabic and Russian characters are not being properly displayed (hex number are appearing instead) Here are the codes I am using: Workable code; without radio button and without JavaScript. -- <!DOCTYPE HTML> <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/> </head> <body><form method="get" action="http://www.google.com/search"><div style="border:0px solid black;padding:40px;width:20em;"><table border="0" align="center" cellpadding="0"><tr><td><input type="text" name="q" size="25"maxlength="255" value="روسيا" /><input type="submit" value="Google" /></td></tr><tr><td align="center" style="font-size:75%"></td></tr></table></div></form></body></html> Un-workable code; with radio button choice and JavaScript -- <HTML><HEAD><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'/><TITLE></TITLE><!-- the search engine script --><script type="text/javascript">function dosearch() {var sf=document.searchform;for (i=sf.sengines.length-1; i > -1; i--) {if (sf.sengines[i].checked) {var submitto = sf.sengines[i].value + escape(sf.searchterms.value);}}window.location.href = submitto;return false;}</script><!-- the search engine script Ends--></HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080"><form name="searchform" onSubmit="return dosearch();"><br /><input name="sengines" type="radio" value="http://www.google.com/search?q=" checked > Google<br /><input name="sengines" type="radio" value="http://www.bing.com/search?q="> Bing<br /><input type="text" name="searchterms" value="روسيا"><input type="submit" name="SearchSubmit" value="Search"></form></BODY></HTML> Upon search submitting you will notice that the characters in the first code in google are displayed correctly and you can see the result of the search. While in the second code :-( Please, I need to know what I am missing in the second code. Thanks in Advance. Link to comment Share on other sites More sharing options...
Ingolme Posted February 10, 2015 Share Posted February 10, 2015 Change the escape() function for encodeURIComponent(). Link to comment Share on other sites More sharing options...
Pol Posted February 10, 2015 Author Share Posted February 10, 2015 Thanks for you fast answer. Problem solved. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now