Geoff Cox said the following on 9/4/2005 12:39 PM:
> On Sun, 04 Sep 2005 03:44:47 -0400, Randy Webb
> <> wrote:
>
>
>>Beyond that, without seeing actual code from the page, including the
>>HTML, it is impossible to tell.
>>
>>It may well also depend on how your AJAX function is setup.
>
>
> Randy,
>
> Wonder if this helps? The first code works OK, the second is the one I
> posted before which has the repeat of the last value - can you see
> what is wrog with the second code?
It helps and points to my original answer. The first approach is
actually a more efficient and preferred way of coding it. The first one
only does one lookup of the innerHTML property, the second does repeated
lookups.
The second difference in the two codes is how you go about adding the
new values to the innerHTML. In the first code, you basically say "OK,
take these values, build a string called str_questions, and then put
that value in the innerHTML of a div tag replacing whatever is in the
div tag". In the second one, you are saying "OK, take these values and
add it to whatever is already in the DIV tag".
And that is where your problem lies (as indicated in my first post).
> Cheers
>
> Geoff
>
> ------------OK code-----------------
>
> function saveIt()
> {
>
> var str_questions = "";
> for (var i=0; i < slider_value.length; ++i)
> {
> str_questions += slider_value[i] + "\n";
> }
>
> document.getElementById("Slider1ValueText").innerH TML = str_questions;
>
> var situation = "Social Group";
> var url = 'http://website/path/formmail-nms2.cgi';
> var pars = 'Situation: ' + situation + ' ' + 'Name: ' + name + ' '
> +
> 'Slider_Values='+document.getElementById('Slider1V alueText').innerHTML;
> var myAjax = new Ajax.Updater('Status', url, {method: 'post',
> parameters: pars});
>
> }
>
> ----------problem code-------------
>
> function saveIt()
> {
>
Add an alert right here:
alert(document.getElementById("SliderValueText").i nnerHTML)
And I bet you will see the last value of your array entries.
> for (var i = 0; i < slider_value.length; i++)
> {
> document.getElementById("Slider1ValueText").innerH TML
> += this.slider_value[i] + " ";
> }
>
> var url = 'http://website/path/formmail-nms2.cgi';
> var pars = 'Situation: ' + situation + ' ' + 'Name: ' + name + ' ' +
> 'Slider_Values='+document.getElementById('Slider1V alueText').innerHTML;
> var myAjax = new Ajax.Updater('Status', url, {method: 'post',
> parameters: pars});
> }
--
Randy
comp.lang.javascript FAQ -
http://jibbering.com/faq & newsgroup weekly