pass value from one html page to another?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    pass value from one html page to another?

    hai experts,
    i am having page called main.html, when the user clicks a button in this page a popup window of pop.html is opened. in pop.html user enter his name and close that popup window.
    now what i need is:
    the name entered in pop.html shiould be shown as table format in main.html. the row should be added each and every time the user open and enter a name.
    without refreshing main.html. what should i do for this.
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    plz try this code .......

    in main.html
    =============== ==
    Code:
    //ur code
    <table id = my_tab>
    </table>
    //ur code
    in pop.html
    =============== ==
    Code:
    <body onbeforeunload = passMain()>
    <input type = text id = ur_name>
    </body>

    in pop.js file
    =============== ===
    Code:
    function passMain()
    {
      var cell_obj = window.opener.document.getElementById('my_tab').insertRow().insertCell()
      cell_obj.innerHTML = doument.getElementById('ur_name').value;
    }
    if u close or refresh the popup html the row will be inserted in main.html

    plz send ur response

    i am online

    Comment

    • nirmalsingh
      New Member
      • Sep 2006
      • 218

      #3
      no reaction in main.html.
      my code:main.html
      Code:
      <html>
      <body>
      <table id = my_tab>
      </table>
      </body>
      </html>
      pop.html
      Code:
      <html>
      <head>
      <script language="javascript" src="pop.js">
      </script>
      </head>
      <body onbeforeunload = "passMain();">
      <input type = 'text' id = 'ur_name'>
      </body>
      </html>
      pop.js
      Code:
      function passMain()
      {
      var cell_obj = window.opener.document.getElementById('my_tab').in sertRow().insertCell()
      cell_obj.innerHTML = doument.getElementById('ur_name').value;
      }

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        In IE, you will need a tbody, so in main.html:
        Code:
        <html>
        <body>
        <table id = my_tab>
        <tbody id="mytb"></tbody>
        </table>
        </body>
        </html>
        and in pop.js:
        Code:
        function passMain()
        {
        var cell_obj = window.opener.document.getElementById('mytb').insertRow().insertCell();
        cell_obj.innerHTML = doument.getElementById('ur_name').value;
        }

        Comment

        • nirmalsingh
          New Member
          • Sep 2006
          • 218

          #5
          still no reaction.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Sorry, typo. Try:
            Code:
            function passMain() {
            var cell_obj = window.opener.document.getElementById('mytb').insertRow().insertCell();
            cell_obj.innerHTML = document.getElementById('ur_name').value;
            }

            Comment

            • dmjpro
              Top Contributor
              • Jan 2007
              • 2476

              #7
              always try to write while u coding js .........

              Code:
              try
              {
               //ur code
              }catch(err)
              {
               alert(err.description);
              }
              then u can trap the error

              now plz check out the case_sensitive id_name my_tab and mytb in main.html and pop.js

              Comment

              • nirmalsingh
                New Member
                • Sep 2006
                • 218

                #8
                send data between html pages?

                hi experts,
                can i send data from one html page to another just like
                main.html?id=sa mple&data
                if yes, how can i retrieve those data by javascript?

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Use location.search and parse it for your values.

                  Comment

                  • nirmalsingh
                    New Member
                    • Sep 2006
                    • 218

                    #10
                    create html table from another page?

                    hi experts,
                    i am having 2 html pages.
                    1.main.html
                    2.sub.html

                    in main.html, when i click a button, sub.html should open in a popup. the user will fill datas in sub.html and close the window. the filled data should be displayed as a table(in main.html along with edit and delete button on each row) at each and every time the user open popup and close. atlast i should be able to edit data by clicking edit button and popup should be opened to edit and after i close the popup, the edited data should be updated, and by clicking delete button current row should be deleted. and at final stage i need the datas in a string to save it in a database.
                    i hope u understood my problem.

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      You have already posted on this (though perhaps in this thread, you have given more information). Please do not double post. I am merging this with the previous thread.

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        Originally posted by nirmalsingh
                        hi experts,
                        i am having 2 html pages.
                        1.main.html
                        2.sub.html

                        in main.html, when i click a button, sub.html should open in a popup. the user will fill datas in sub.html and close the window. the filled data should be displayed as a table(in main.html along with edit and delete button on each row) at each and every time the user open popup and close. atlast i should be able to edit data by clicking edit button and popup should be opened to edit and after i close the popup, the edited data should be updated, and by clicking delete button current row should be deleted. and at final stage i need the datas in a string to save it in a database.
                        i hope u understood my problem.
                        Why go through the hassle of passing values between pages? Just allow the user to edit values directly in the page by showing a text box with the value when you click on edit. Alternatively, just show a prompt box and use the edited value to dynamically change the current value.

                        Comment

                        • nirmalsingh
                          New Member
                          • Sep 2006
                          • 218

                          #13
                          popup box to enter values??

                          hi all! i need a popup box to enter values. it should be cross browser compatibility. what should i do?

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #14
                            Merged threads. Follow the suggestion that I posted earlier in this thread. If you still have problems, post your code.

                            Comment

                            • persiangulf
                              New Member
                              • Oct 2009
                              • 2

                              #15
                              Hi,

                              I have a question regarding this passMain function,
                              Unfortunately I cant reach my admin, How can I allow my members to download the .wmv file from this code:

                              Code:
                              <img onmouseout="                  swapImage(vid_5738, '/web/vod/images/5738.png')
                                              " onmouseover="                  swapImage(vid_5738, '/web/vod/images/5738NAV.png')
                                              " onclick="                  passMain('5738', 'http://38.117.88.50/N/TV_Series/BooyeGolhayeVahshi/BooyeGolhayeVahshi_01.wmv', 'WB100619');window.parent.chName='Booye Golhaye Vahshi - 1';
                                              " style="position: absolute; top: 8px;" src="/web/vod/images/5738.png" name="                  vid_5738" id="vid_5738" class="logo"/>
                              Before it used to be the file.wmv?sid=va lue&vid=value
                              But it wont work now, please help me with this issue

                              Comment

                              Working...