Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Value from a Javascript Function

Status
Not open for further replies.

Garabaldi

Technical User
Jan 16, 2002
61
0
0
CA
Hiya Folks...

I need to determin what language the user's browser is set up as (ie: english or french).

I have the javascript code that will read this off of IE (var lang = navigator.userLanguage;).

Now I am trying to pass this information to a form so I can mail it off to a php page and render either an english or french page...

Can someone please show me how to pass a javascript value to a form??

Thanks,

Angelo
 
Add a hidden field to the form. Set the value of the field with Javascript.
Code:
<html>
...
<form name="whoosurdady" onsubmit="return setValues();">
...
<input type="hidden" name="user_language" value="">
...
</form>
<script>
function setValues(){
  document.whoosurdady.user_language.value = navigator.userLanguage;
...
  return true;
}
</script>
...
</html>
If you already have validation code in the onsubmit event handler, just add the line of code to that function.

My Dynamic HTML: The Definitive Reference by Danny Goodman from O'Reilly mentions other properties related to language, browserLanguage, language, systemLanguage. Only language was available in Netscape 4. That may have changed.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top