Hi
I have made a form that post values through a preview page to a servlet. The preview page is a javascript on the form page. On the preview page ÆØÅ become ÆØÅ, but when they are sendt to the servlet the become strange signs? Why does this happend? What can I do to prevent this?
Here is my code:
Jørn Arild Andenæs
jaa@jaa.no
I have made a form that post values through a preview page to a servlet. The preview page is a javascript on the form page. On the preview page ÆØÅ become ÆØÅ, but when they are sendt to the servlet the become strange signs? Why does this happend? What can I do to prevent this?
Here is my code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>NIK 2004 - Påmeldingsskjema</title>
<H1>NIK 2004 - Påmeldingsskjema</H1>
<script Language="JavaScript"><!--
function preview(){
if(document.theForm.innkvartering[0].checked) {innkvartering="Hotell";}
else{ innkvartering="Ordner selv";}
tekst="<html><head></head><body>"
tekst="<form action='servlet/PaameldingServlet' method='post'>"
tekst=tekst+"<table width='400'>"
tekst=tekst+"<tr><td>Fornavn:</td><td>"+document.theForm.fornavn.value+"<input type=hidden name='fornavn' value='"+document.theForm.fornavn.value+"'></td></tr>"
tekst=tekst+"<tr><td>Etternavn:</td><td>"+document.theForm.etternavn.value+"<input type=hidden name='etternavn' value='"+document.theForm.etternavn.value+"'></td></tr>"
tekst=tekst+"<tr><td>Epost adresse:</td><td>"+document.theForm.epost.value+"<input type=hidden name='epost' value='"+document.theForm.epost.value+"'></td></tr>"
tekst=tekst+"<tr><td>Telefon:</td><td>"+document.theForm.telefon.value+"<input type=hidden name='telefon' value='"+document.theForm.telefon.value+"'></td></tr>"
tekst=tekst+"<tr><td>Institusjon:</td><td>"+document.theForm.institusjon.value+"<input type=hidden name='institusjon' value='"+document.theForm.institusjon.value+"'></td></tr>"
tekst=tekst+"<tr><td>Adresse:</td><td>"+document.theForm.adresse.value+"<input type=hidden name='adresse' value='"+document.theForm.adresse.value+"'></td></tr>"
tekst=tekst+"<tr><td>Postnr:</td><td>"+document.theForm.postnr.value+"<input type=hidden name='postnr' value='"+document.theForm.postnr.value+"'></td></tr>"
tekst=tekst+"<tr><td>Poststed:</td><td>"+document.theForm.poststed.value+"<input type=hidden name='poststed' value='"+document.theForm.poststed.value+"'></td></tr>"
tekst=tekst+"<tr><td>Innkvartering:</td><td>"+innkvartering +"<input type=hidden name='innkvartering' value='"+innkvartering+"'></td></tr>"
tekst=tekst+"<tr><td colspan=2 align='center'><input type='button' value='Forkast' onclick='history.back()'> <input type='submit' value='Godkjenn' name='sendt'></td></tr>"
tekst=tekst+"<tr><td colspan=2 align='center'><a href='index.jsp'>Til hovedsiden</a></td></tr>"
tekst=tekst+"</table>"
tekst=tekst+"</form>"
document.write (tekst);
}
//--></script>
</head>
<body>
<form name="theForm" action="javascript: preview()" method=post >
<table width="400">
<tr><td><font color="#FF0000" size="1">*</font> Fornavn:</td><td><input type=text name="fornavn" maxlength=64 size=40></td></tr>
<tr><td><font color="#FF0000" size="1">*</font> Etternavn:</td><td><input type=text name="etternavn" maxlength=64 size=40></td></tr>
<tr><td><font color="#FF0000" size="1">*</font> Epost adresse:</td><td><input type=text name="epost" maxlength=255 size=40></td></tr>
<tr><td> Telefon:</td><td><input type=text name="telefon" maxlength=15 size=15></td></tr>
<tr><td><font color="#FF0000" size="1">*</font> Institusjon:</td><td><input type=text name="institusjon" maxlength=255 size=40></td></tr>
<tr><td><font color="#FF0000" size="1">*</font> Adresse:</td><td><input type=text name="adresse" maxlength=255 size=40></td></tr>
<tr><td><font color="#FF0000" size="1">*</font> Postnr:</td><td><input type=text name="postnr" maxlength=4 size=6></td></tr>
<tr><td><font color="#FF0000" size="1">*</font> Post sted:</td><td><input type=text name="poststed" maxlength=255 size=40></td></tr>
<tr><td valign="top"> Innkvartering:</td><td><input checked type=radio name="innkvartering" value="Hotell"> Hotell<br><input type=radio name="innkvartering" value="Ordner selv"> Ordner selv</td></tr>
<tr><td colspan=2 align="center"><input type=RESET value="Fjern alt"> <input type="submit" value="Bekreft" name="sendt"></td></tr>
<tr><td colspan=2 align="center"><a href="index.jsp">Til hovedsiden</a></td></tr>
<tr><td colspan=2><p><font color="#FF0000" size="1">*</font><i> må fylles ut!</i></td></tr>
</TABLE>
</FORM>
</BODY>
</html>
jaa@jaa.no