Assigning Hidden fields using Javascript

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am working on a Perl program which dynamically creates an HTML form
by appending data to the $html variable.  In order for me to have the
write data to the database, I need to have Javascript set the values of
two hidden forms.  The entire web page is contained in a form called

Here are the hidden fields:
$html .= qq`<input type="hidden" name="SGROUP" value="">`;
$html .= qq`<input type="hidden" name="STYLE" value="">`;

Within the JavaScript I assign values to these hidden fields and then I
use alert check to test to see if their values have been assigned
correctly.  Within the Javascript, their values are assinged correctly!
 For example, I will explicitly show this

For example:
#Here is the javaScript function

function do_processForm()
         var stopper;
         var i;
         var selectedSG;
         var concat;
         var styleSelect;
         loopcounter = document.Allan.RADEO.value;
         //alert('This is loopcounter ' + loopcounter);
         for (i=0;i<loopcounter;i++){

             selectedSG = document.Allan.SGGroup[i].value;
             stopper = i;

       //concat = "st"+stopper;
       document.Allan.SGROUP.value = selectedSG;
       alert('Checking for hidden field' +
       //The alert pop-up generated produces the correct result
      //suggesting that hidden field "SGROUP" has been assigned the
     //correct value
    //Javascript continues.....

At the end of the Perl script, I print the HTML and all the
dynamic HTML has been generated, however SGROUP has "" value.  Can
anyone make sense of this?  


Re: Assigning Hidden fields using Javascript wrote:
<snip stuff>

If I understand this corrrectly, if Perl generates this:
Quoted text here. Click to load it

And with JavaScript your are setting the values here

Quoted text here. Click to load it


Quoted text here. Click to load it

And you are check the source code and notice the hidden fields are still
blank, well of course they would be. The HTML would only reflect what
was sent and generated by the webserver, i.e. the Perl script.
JavaScript runs on the client machine may change the field values but
you will not see it in the source. Only after the form is process will
your see the values in the receiving script.

Client-side JavaScript generated code is never seen in the View Source
of a browser, with one exception. Netscape 4.x would show JavaScript
generated code upon the initial loading of the page, not of course for
DHTML changes after the pages loaded.

Maybe I should ask, how are you checking if SGROUP values have been changed?

Take care,

Re: Assigning Hidden fields using Javascript

Hi Mr. Little,
I realised exactly what you said a minute after I sent the posting.
Again, thanks for responding.  You're a great guy.
Thanks again,

Re: Assigning Hidden fields using Javascript wrote:

Quoted text here. Click to load it
Quick tip though Allan, this news group as with most want you to quote
the bits of the previous message and write your response below. Just
like I did here....

Take care,

Site Timeline