Javascript+radio button+maintain value after submit

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..

[1724 byte] By [ali_hammada] at [2007-11-27 9:51:40]
# 1
There are two options-1. After submit the page gets reloaded adn all the values gets lost, so u need to send the same value back to the page. by setting in request object etc.2. Use Ajax call.
richa2608a at 2007-7-13 0:20:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

1. Use Custom tags. THe plain html tags wont be able to get the data automatically from the form. Use something like <html:text> instead of <intput> tag.

2. I think u r forwarding it to a jsp instead of a servlet.

Posting the full code required might help in understanding the problem properly.

vinayak_ra at 2007-7-13 0:20:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...