Sure thing.  First, a little info on _javascript_.  Once the page is
downloaded into your browser, the browser takes the DOM and loads it into
memory.  Thus, when you modify the value of your hidden field,
outputselection, it is being modified in memory and not in the actual source
code.  Displaying the source code will not show you any changes in the
values of your _javascript_ variables, even though those variables have been
modified.  This is the nature of a client side scripting language, and one
of the reasons _javascript_ is so difficult to debug.


To populate the value of the textbox with the value of the hidden variable,
simply put this code in the "subme()" function.


    document.frm.txtarea1.value = document.frm.outputselection.value;


One other suggestion.  If you are going to have your "subme()" function call
the submit event for the form, I would change the "TYPE" of your button from
"SUBMIT" to "BUTTON".

-----Original Message-----
From: Allan Clarke [mailto:[EMAIL PROTECTED]
Sent: Monday, October 20, 2003 9:44 AM
To: CF-Talk
Subject: Form and hidden variable question

Hi Guys,

I desparately need somebody to help me. I have a form
which has hidden variable, a textarea and a submit
button. When the submit button is clicked a OnClick
event calls a function subme() method. Here is my code

<form name="frm" method="post">
<input NAME="update" TYPE="submit"
VALUE="Calculate">
<textarea name="txtarea1" cols="40"
rows="5"></textarea>
<input type="hidden" name="outputselection" value="">
</form>

Here is the javacript code:

<script LANGUAGE="_javascript_">
function subme() {
method1();
document.frm.outputselection.value = PagecontentA +
PagecontentB + PagecontentC;
alert(document.frm.outputselection.value);
document.frm.submit();
}

function method1(){
PagecontentA ="Hello";
PagecontentB ="And";
PagecontentC ="Welcome";
}

</script>

When browsed in the browser on form submission the
alert displays the value "Hello And Welcome" but for
some reason when I view the source in the browser the
value of the hidden variable "outputselection" is
empty. I want to populate the textbox with the value
in the hidden variable. I am struggling to do this.
Can somebody please show me how to do this, I would
really appreciate your help

Best Regards,
Allan

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com <http://shopping.yahoo.com>  
  _____  


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to