Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Using OnChange or OnBlur to changes the value of a hidden field

Community Beginner ,
May 30, 2006 May 30, 2006
I have a need to update the value of a hidden field with the value of a list menu. I researched the OnBlur and OnChange JavaScript functions but did not find anything suitable. Here's the deal:

If a user selects California from a State list menu, I need to immediately update the the value of a hidden field with 'California' . (Both fields are on the same page) All of this has to happen BEFORE the user Submits the page. Anytime they select the state from the list menu the hidden field value has to change.

Can anyone offer any suggestions?

Thank you!
TOPICS
Server side applications
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , May 30, 2006 May 30, 2006
Yep, that did the trick for the hidden field. Many thanks.

Will I be able to also store that value into a session variable? (see previous post)
Translate
LEGEND ,
May 30, 2006 May 30, 2006
Here you go...let us know if this is what you wanted.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<script language=javascript>
function copydafields(){
document.daform.text2.value=document.daform.text1.value
return true
}
</script>
<form action="" method="post" name="daform" id="daform">
<p>Master:
<input name="text1" type="text" id="text1"
onBlur="copydafields(this.form)">
</p>
<p>Hidden:
<input name="text2" type="text" id="text2">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>



"PA" <webforumsuser@macromedia.com> wrote in message
news:e5ibjh$f45$1@forums.macromedia.com...
>I have a need to update the value of a hidden field with the value of a
>list
> menu. I researched the OnBlur and OnChange JavaScript functions but did
> not
> find anything suitable. Here's the deal:
>
> If a user selects California from a State list menu, I need to immediately
> update the the value of a hidden field with 'California' . (Both fields
> are on
> the same page) All of this has to happen BEFORE the user Submits the
> page.
> Anytime they select the state from the list menu the hidden field value
> has to
> change.
>
> Can anyone offer any suggestions?
>
> Thank you!
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 30, 2006 May 30, 2006
That looks like it may work! I'll check it out and get back to you. Thanks for the quick response.

If I change the field type of Field2 to Hidden, I should get the same results, right?

As long as I'm here: I may also need to store the selected value as an ASP Session Variable. (In addition to, or as an alternative to the hidden field) Is this possible?

Thanks again!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 30, 2006 May 30, 2006
LATEST
Yep, that did the trick for the hidden field. Many thanks.

Will I be able to also store that value into a session variable? (see previous post)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines