Passing the values from one div to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • visky
    New Member
    • May 2013
    • 3

    Passing the values from one div to another

    I have dynamically loaded a page,in that i have two <div> the required values or the datas displayed in the one <div> or iframe and values passed using forms post methods to another file.that should reflect in another div or iframe as a result.
    Please help me to solve this....
    Thank u
    Last edited by acoder; May 22 '13, 04:31 PM. Reason: Moved to JavaScript forum
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Use ajax to submit the data and take it's return value and put it in the other div.

    Comment

    • visky
      New Member
      • May 2013
      • 3

      #3
      I dont know ajax coding.I have attached a sample code can you please alter it.
      I have 3 files.
      =============== =============== =============== =========
      main.html
      Code:
      <html >
      
      <head>
      
      
      </head>
      
      <body>
      
      <div id="leftbar" style="background-color:#eeeeee;width:400px;height:1000px;float:left;position:absolute;">
      <iframe src="form.html" width="1050px" height="1500px" seamless></iframe>
      </div>
      
      <div  id="container" style="background-color:#FFD700;height:1000px;width:990px;float:right;">
      <iframe src="process.php" name="content" width="1050px" height="1500px" seamless></iframe>
      </div>
      
      </body>
      
      </html>
      ===================================================
      form.html
      <html >
      <head>
      </head>
      <body>
      <form name="myform" action="process.php" method="POST"  >
          <input type="hidden" name="check_submit" value="1" />
      
          Choose the colors:       <br>
            <input type="checkbox" name="Colors[]" value="green" checked="checked" onclick="document.forms.myform.submit();"/> Green<br>
            <input type="checkbox" name="Colors[]" value="yellow" onclick="document.forms.myform.submit();" /> Yellow             <br>
            <input type="checkbox" name="Colors[]" value="red" onclick="document.forms.myform.submit();"/> Red                    <br>
            <input type="checkbox" name="Colors[]" value="gray" onclick="document.forms.myform.submit();" /> Gray                 
      </form> 
      </body>
      </html>
      ================================================
      process.php
      <html >
      <head>
      </head>
      <body>
      <?php
      if (array_key_exists('check_submit', $_POST)) {
       if ( isset($_POST['Colors']) ) {
           $_POST['Colors'] = implode(', ', $_POST['Colors']); 
          
        }
       echo "Colors you chose: {$_POST['Colors']}<br />";
      }
      ?>
      
      </body>
      
      </html>
      Last edited by Rabbit; May 22 '13, 04:04 PM. Reason: Please use code tags when posting code.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Please use code tags when posting code.

        Sorry, we are not here to do the work for you. We can help you with any problems you run into along the way though. To get started, you will want to learn AJAX. It's easy if you already know Javascript and PHP. Here's a good tutorial to start with: http://www.w3schools.com/ajax/.

        Comment

        • visky
          New Member
          • May 2013
          • 3

          #5
          I need to finish this work as early as possible and struck in the middle so posted code.Will learn AJAX.
          Thank you so much...

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            Good luck. Let us know if you have any questions. It looks like you already know javascript and php so it should be relatively easy to pick up since it's not a new language but just a way to use the two in conjunction.

            Comment

            Working...