[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 150
  • Last Modified:

Using Two Frames, Capture the value of a <select> option and set it to a variable

Hello Experts,

I have an JSP page with two frames.  Upon a submit, I want to capture the value of one of my frames(frame1) and set it to a variable (i.e. Java variable) in my other frame (frame2).  For example,

frame1:
<form name="test">
<select name="count">
  <option value="0">0</option>
  <option value="5">5</option>
  <option value="10">10</option>
</select>
<input type=submit>
</form>

frame2

//get the value from "count"
int mycount = count;

How can this be done?  I tried setting a hidden variable in frame2 and setting it from frame1 upon a submit, but that didn't seem to work.
Ex:

frame1:

//Javascript
 parent.positions.document.forms[''].elements['mytest'].value=
              document.forms[0].elements['count'].options[
                  document.forms[0].elements['count'].selectedIndex
              ].value;    

frame2:

 <input type="hidden" name="mytest" value=""> //can I somehow extract this value in my page and set it to a variable?

Thank you for your help!
0
jollykh
Asked:
jollykh
1 Solution
 
fargoCommented:
Let me clarify.

1)You want to set the hidden parameter of frame2 when the frame1 is submitted?? Is it?

2)Or you want to take a value from frame 2 and set the value in frame1 ?

2nd option is quite possible. The first option is not.

regards,
fargo
0
 
jollykhAuthor Commented:
Hello Fargo,

I'm looking at option 1.  This is possible through javascript (see the snippet of code in my originial question).  My question is once I <b>set</b> the value, can I <b>get</b> the value in the JSP?

Thanks!
0
 
TimYatesCommented:
you could have a third hidden frame which posts the value to frame 2 before posing this form to frame 1

Tim
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jollykhAuthor Commented:
I have come to discover that the only was I can get this accomplished is by calling the request.getParameter from my java class and setting the variable to the session.

Thanks everyone for your help!
0
 
TimYatesCommented:
ok by me
0
 
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now