Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javascript+radio button+maintain value after submit

843838Jul 6 2007 — edited Jul 6 2007
Hi

I have three radion buttons on a page, when a radio button is selected the page is resubmitted.

Problem:
------------
First Approach
-------------------
I save the value of radio button( in onClick() function) to a global variable and then submit the page like this
<script>
var val = ' '; // The global variable
function radioChk(radioObj)
    {
      val = radioObj.value;
      document.POPUP.submit()
     }
    }
    </script>
But when i access the same variable after page resubmission, i can't get the stored value, perhaps because page resubmitted and the value is again set to default.

Secon Approach:
-----------------------

Instead of global variable, i declare a Hidden field and assign the value on onClick method to the hidden field like this..
function radioChk(radioObj)
    {
      document.myForm.hiddenField.value = radioObj.value;
      document.POPUP.submit()
     
    }
    </script>
But again when i access the value after resubmission in the form i can't get the value probably because it is again set to default.. like this
<body >
<FORM NAME="myForm"   METHOD="POST" 		ACTION="AssignSupportStaffToSubPopup.jsp">
<INPUT TYPE="HIDDEN" NAME="hiddenField" value="">
Please specify how can i maintain the value so that i could access it after resubmission..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 3 2007
Added on Jul 6 2007
2 comments
360 views