value from javascript to my jsp page
hi friends,
I have a submit button and its onclick event I have called a javascript.
this javascript have a prompt and the user will enter the value in it.
i want this value into a hidden input field,which is there in jsp page.
please help me
[273 byte] By [
java@mania] at [2007-11-27 10:35:05]

# 2
I believe you mean, you want to pop up a dialog box from a parent JSP page, have someone enter data in a textfield in the pop up, and when he clicks the button on the pop up, have the data copied into a hidden textfield on the parent page.
If you look up the following two items in a javascript book, I believe you will find examples of how to do this:window.open(),and 'opener'.
You call window.open() to pop up a window, then in the pop up window, you add an onClick event to your button that writes back to the parent page hidden textfield.
For Example, something like this (will not compile):
on the pop up javascript function:
opener.document.parentFormName.textField1.value=document.popUpForm.textField.value;
In the above, the left hand refers to a textfield on the parent, the right hand refers to a textfield on the pop up. Sorry, cant go into it further.
# 5
Considering the hidden field is declared like this
<input type="hidden" id="hiddenFieldId" name="hiddenFieldName" value="" />
Write a js which accepts a value and sets it to the hidden field
<script type="text/javascript">
function submitValue(){
var y=window.prompt("please enter the value")
document.getElementById('hiddenFieldId').value=y;
return true;
}
</script>
The submit button should have a "return" when calling the js.
<input type="submit" onClick="return submitValue()"/>