U
U?ur Aslan
I made a form that includes a list box (select-options) that has
numbers from 1 to 10 as option values. When user selects one of the
numbers from the list box, an innerHTML is inserted into a "div" part
in the page as much as the selected number value. This is done by a
javascript that is handled by onchange event in <select> tag. Once the
form is submitted by user, the user can go back to change the values
that he has written in the form. The problem is that when the user
hits the back button, the value selected in list box remains same but
the innerHTML part disappears as if user did not select any number.
This can be natural and normal but I need a solution. If you can help
me, I will be very pleased. Thank you.
The code : (options tags are filled by ASP)
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function degistir(sayi){
if (sayi != 0){
var text2 = "";
for (i=1; i<= sayi; i++)
{
text2= text2 + i + "Hello!<br>"
}
var Divx = document.getElementById("div1");
Divx.innerHTML = text2;
}
}
</SCRIPT>
</HEAD>
<BODY>
<form name=form1>
<Select name=select1
onchange="degistir(this.options[this.selectedIndex].value)">
<option value="0">Seçiniz
<% for i=1 to 10 %>
<option value=<%=i%>><%=i%>
<% next %>
</select>
<input type="submit" value="git">
</form>
<div id="div1"></div>
</BODY>
</HTML>
numbers from 1 to 10 as option values. When user selects one of the
numbers from the list box, an innerHTML is inserted into a "div" part
in the page as much as the selected number value. This is done by a
javascript that is handled by onchange event in <select> tag. Once the
form is submitted by user, the user can go back to change the values
that he has written in the form. The problem is that when the user
hits the back button, the value selected in list box remains same but
the innerHTML part disappears as if user did not select any number.
This can be natural and normal but I need a solution. If you can help
me, I will be very pleased. Thank you.
The code : (options tags are filled by ASP)
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function degistir(sayi){
if (sayi != 0){
var text2 = "";
for (i=1; i<= sayi; i++)
{
text2= text2 + i + "Hello!<br>"
}
var Divx = document.getElementById("div1");
Divx.innerHTML = text2;
}
}
</SCRIPT>
</HEAD>
<BODY>
<form name=form1>
<Select name=select1
onchange="degistir(this.options[this.selectedIndex].value)">
<option value="0">Seçiniz
<% for i=1 to 10 %>
<option value=<%=i%>><%=i%>
<% next %>
</select>
<input type="submit" value="git">
</form>
<div id="div1"></div>
</BODY>
</HTML>