0

Hi,

I'm trying to use the request.getParameter("myInputField") on Page A. The problem is that the input field "myInputField" is on Page B. Does anyone know of a way to retrieve from Page A, the value of the input field that is on Page B?

Thanks,
-Ash

2
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by AshtonHogan
0

Hi,

I'm trying to use the request.getParameter("myInputField") on Page A. The problem is that the input field "myInputField" is on Page B. Does anyone know of a way to retrieve from Page A, the value of the input field that is on Page B?

Thanks,
-Ash

You need to submit the form that is at Page B to the Page A.
In details:
>The input field must be inside a form tag
>When you submit, the control will be transferred to the page that you define at the action attribute of the form tag
> At the next page you will have access to everything the form tag contained:

<form action="pageB.jsp">

<input type="text" name="myInputField" />
<input type="submit" value="Click here to submit" />

</form>

pageB.jsp:

<%
String myInputField = request.gteParameter("myInputField");
%>
0

Say for example, the submit does not change Page A to Page B, but makes a popup of Page B instead? While Page A remains active in the background. Bare in mind that Page A will still use a form "post" once the button that brings up the pop up is clicked.

0

Page A:
(This is the page that holds the input area's and submit button)

<script type='text/javascript'>
function startPopUp() {
document.PageAForm.submit();
window.open("searchRequestPopUp?searchId=" +  request.getParameter('searchPhrase') + ",'window','width=800,height=300','scrollbars=yes','resizable=yes','statusbar=yes','menubar=yes','toolbar=yes','dependent=yes');
}
</script>

<input type='submit' value='Search' name='sourceListSearch' onclick='startPopUp()'/>

Page B:
(This is the pop up window that I want to have the ability to reference the input area's from Page A)

out.println(""+request.getParameter("searchId"));

This DOES work, the problem, however, is that the first time Page B (the pop up) is loaded, the value is null; and if you submit Page A again, then Page B recognises the first input that was submitted on Page A instead of the second one.
For example: If I typed in "2" on Page A and sent it across to Page B, then Page B would display "null". If I typed "3" on Page A and clicked submit again then Page B will display "2" (The first value that was entered).
So in other words, Page B (The Pop Up) is always one step behind.

Thanks again,
-Ash

0

I've also tried hardcoding the number "2" into the input area on Page A that I want to reference on Page B. The first time the pop up runs, the output printed is still "null".

0

The first time the page loads this is null:

request.getParameter('searchPhrase')

So this is translated to:

window.open("searchRequestPopUp?searchId=null", . . .

So when the pop up opens the searchId has value "null".

But after you submit the form of page A you send at the request the "searchPhrase" so this has value:

window.open("searchRequestPopUp?searchId=valueEntered", . . .

And you get it at the pop up.

I would suggest to remove this line:

function startPopUp() {
// REMOVE //document.PageAForm.submit();
window.open("searchRequestPopUp?searchId=" +  request.getParameter('searchPhrase') + ",'window','width=800,height=300','scrollbars=yes','resizable=yes','statusbar=yes','menubar=yes','toolbar=yes','dependent=yes');
}

You don't need it. All you need is to open the new page with what you entered at the search text. Right? Then you can do this:

<script type='text/javascript'>
function startPopUp() {

var v = document.getElementById("searchPhraseId").value;

window.open("searchRequestPopUp.jsp?searchId=" +  v, 'window','width=800,height=300','scrollbars=yes','resizable=yes','statusbar=yes','menubar=yes','toolbar=yes','dependent=yes');

}
</script>

<input type="text" name="search" id="searchPhraseId">

<input type='button' value='Search' name='sourceListSearch' onclick='startPopUp()'/>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.