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]
# 1

why don't you try:

<script ...>

function call() {

formName.prompt.value = .....;

}

</script >

<form name="formName">

<input name = "prompt">

<input type="submit" onclick="call()">

</form>

jorgechavez77a at 2007-7-28 18:32:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

George123a at 2007-7-28 18:32:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

thanks jorgechavez77,

I have tried this methosd but it stores a null value into it.

any ways thank u !!

java@mania at 2007-7-28 18:32:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

hi George123 ,

Thank u!!

hey george i think this can help me but please give me what u want to say in detail as u left it incomplete.

please help !!!

java@mania at 2007-7-28 18:32:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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()"/>

R@njita at 2007-7-28 18:32:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Hi R@njit ,

Thank you for your reply. This really worked and could solve my problem in a very easy way.

Thanks for the reply.

java@mania at 2007-7-28 18:32:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...