Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6157885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:51:44+00:00 2026-05-23T20:51:44+00:00

I have one page which enable user to choose something in a new window:

  • 0

I have one page which enable user to choose something in a new window:

Page1.html:

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-type">
    </head>
    <body>
        <form action="update.action">
            <input name="val1" type="text" id="val1" value="" readonly="readonly"> <input type="button" name="Submit2" value="select value" onclick="javascript:window.open('page2.html','','width=750,height=500,scrollbars=yes');">
            <br/>
            <input name="val2" type="text" id="val2" value="" readonly="readonly"> <input type="button" name="Submit2" value="select value" onclick="javascript:window.open('page2.html','','width=750,height=500,scrollbars=yes');">
        </form>
    </body>
</html>

page2.html:

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-type">
    </head>
    <body>
        <input type="checkbox" value="Bike" />Bike<br/>
        <input type="checkbox" value="Car" />Car<br/>
        <input type="button" value="OK" id="sub"/>
        <script type="text/javascript">
            document.getElementById("sub").onclick=function(){
                var cks=document.getElementsByTagName('input');
                var vals="";
                for(var i=0;i<cks.length;i++){
                    if(cks[i].checked){
                        vals+=','+cks[i].value;
                    }
                }
                window.opener.document.getElementById('val1').value=vals;
                window.close();
            }
        </script>
    </body>
</html>

The data user choosed in page2.html should be send to page1.html.

Now I have two questions:

1)how did the page2.html know which <input type=text> should used to fill the selected result?

For example,in the page1.html,there are two input: “val1” and “val2”,when user click the button after “val1”,then he select something,the selected value should be filled to the “val1” input.

2)Since I enable user select multiple items. For example, if user click the button after “val1”,then user can select both “car” and “bike” in the page2.html,then the value “car,bike” will be filled to the “val1” input.

When the form is submitted,the value I got in the server side will be “car,bike”.

That’s to say the posted parameter is :

val1:bike,car.

But I want this way since I hold a array object in the server side:

val1:bike
val1:car

Any way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:51:45+00:00Added an answer on May 23, 2026 at 8:51 pm

    You need do extra processing of onclick events in page1.html to make it remember which element should be filled with result. And then in page2.html you need to access this value using .opener property.

    If you want to send array of values to the server, you need to pass it as array. So, you need to create input named “val1[]” for each value.

    EDIT Here’s modified code of page1 and page2 to make you see what I mean answering first part of the question.

    page1.html

    <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-type">
    </head>
    <body>
        <script>
        var openerInput = 'val1';
        function openwindow(id) {
            openerInput=id;
            window.open('page2.html','','width=750,height=500,scrollbars=yes');
        }
    </script>
        <form action="update.action">
            <input name="val1" type="text" id="val1" value="" readonly="readonly"> <input type="button" name="Submit2" value="select value" onclick="openwindow('val1')">
            <br/>
            <input name="val2" type="text" id="val2" value="" readonly="readonly"> <input type="button" name="Submit2" value="select value" onclick="openwindow('val2')">
        </form>
    </body>
    </html>
    

    page2.html

    <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-type">
    </head>
    <body>
        <input type="checkbox" value="Bike" />Bike<br/>
        <input type="checkbox" value="Car" />Car<br/>
        <input type="button" value="OK" id="sub"/>
        <script type="text/javascript">
            document.getElementById("sub").onclick=function(){
                var cks=document.getElementsByTagName('input');
                var vals="";
                for(var i=0;i<cks.length;i++){
                    if(cks[i].checked){
                        vals+=','+cks[i].value;
                    }
                }
                window.opener.document.getElementById(window.opener.openerInput).value=vals;
                window.close();
            }
        </script>
    </body>
    </html>
    

    UPD:

    To answer the second part of your question, here’s the example how the input fields should look

    <input name="items[]" value="apples" />
    <input name="items[]" value="oranges" />
    <input name="items[]" value="bananas" />
    

    It will be sent to the server as array. But maybe you’d better leave it as is now, and just split the value by “,” on the server side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one aspx page with some controls. Also i have one DIV which
If I have a page with outputcaching (let's call it Employees.aspx) which accepts one
Suppose I have one html page with frames. The left frame is simply a
I have 2 textbox in my asp.net page and also have one hiddenfield in
Many applications have grids that display data from a database table one page at
I have two forms on a page (one is being grabbed by AJAX). I
I have a page that has an iframe From one of the pages within
I have a custom aspx page loaded in a IFrame in one of the
I have a page with 3 layers, one for navigation, one for database records
I have a page with two ContentPlaceHolders. One has a DropDown and another UpdatePanel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.