473,325 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Text box value keeps resetting after submit

Hello everyone,

I have a small problem with javascript below:

<p>Slider Test</p>
<div class="slider" id="slider1" tabIndex="1">
<input class="slider-input" id="slider1_input"/>
</div>
<form id="slider1_form" method="get" action="/protect/control.htm">
Value:<input type="text" name="slider1_output" id="slider1_disp"
value="5"/>
</form>

<script type="text/javascript">
var sdr1 = new Slider(document.getElementById("slider1"),
document.getElementById("slider1_input"));

sdr1.onchange = function ()
{
document.getElementById("slider1_disp").value = sdr1.getValue();
document.getElementById("slider1_form").submit();
};
</script>

I got the slider's onchange function to trigger the form GET function,
and the web server can get the slider value properly. However, after
that, the value of the input text box (id="slider1_disp") returns to 5
(or whatever default value I put at the input text box). How do I
prevent the value of the input text box to return to the default value
(i.e. I want to keep the last value that is submitted).

Any suggestion is welcome. Thank you in advance!
Regards,
James
Jun 27 '08 #1
1 1800
SAM
ha*********@gmail.com a écrit :
Hello everyone,

I have a small problem with javascript below:

<p>Slider Test</p>
<div class="slider" id="slider1" tabIndex="1">
<input class="slider-input" id="slider1_input"/>
</div>
<form id="slider1_form" method="get" action="/protect/control.htm">
Value:<input type="text" name="slider1_output" id="slider1_disp"
value="5"/>
</form>

<script type="text/javascript">
var sdr1 = new Slider(document.getElementById("slider1"),
document.getElementById("slider1_input"));
what that is supposed/expected to do ?
sdr1.onchange = function ()
{
document.getElementById("slider1_disp").value = sdr1.getValue();
document.getElementById("slider1_form").submit();
};
</script>

I got the slider's onchange function to trigger the form GET function,
and the web server can get the slider value properly. However, after
that, the value of the input text box (id="slider1_disp") returns to 5
(or whatever default value I put at the input text box). How do I
prevent the value of the input text box to return to the default value
(i.e. I want to keep the last value that is submitted).

Any suggestion is welcome. Thank you in advance!
I suppose 'control.htm' contents your form "slider1_form" ?
I understand you can't do the job server side.

JS in header :
==============

var v = self.location.toString().split('?')[1];
if(v.indexOf('&')>0) {
v = v.split('&');
for(var i=0, n = v.length; i<n; i++)
if(v[i].indexOf('slider1_disp')>=0) {
v = v[i].split('=')[1];
break;
}
}
else v = v.split('=')[1];

// if there is no other window.onload :
window.onload = function() {
document.getElementById("slider1_disp").value = v;
}
or, just before </body>

<script type="text/javascript">
document.getElementById("slider1_disp").value = v;
</script>

--
sm
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
5
by: andy.lee23 | last post by:
hi im having trouble counting lines in a text file, i have the following code int node1, node2, i; char name; float value; ifstream fin; fin.open(OpenDialog1->FileName.c_str()); i=1;
8
by: Nathan Sokalski | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. After the file is successfully submitted, I want the field to be reset so that the user knows the file was...
8
by: Nathan Sokalski | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. After the file is successfully submitted, I want the field to be reset so that the user knows the file was...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.