Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Submitting html form in php

This is my first.php page html part. I have a form including a div and a submit button. I want when button clicked, open a new page (second.php) and display contents of div(id=orderList)

<form id="orderForm" action="second.php">
 <div class="col-md-5" id="orderList">
 <h3 align="center">Sipariş Listesi</h3>
 </div> 
 <div>
 <button type="submit" id="firstConfirmButton" class="btn btn-primary btn-lg">Onayla</button>
 </div>
</form>

This is javascript part;

 $("#orderForm").submit(function() {
 var content = $('#orderList').html();
 console.log(content); //(no problem everything is ok)
 $('#confirmForm').val(content);
 var content2 = $('#confirmForm').html();
 console.log(content2); //(it is null)
}); 

And this is second.php where I want to display the contents in the div(id=confirmForm)

<html>
 <head> 
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
 <script type="text/javascript" src="script.js"></script>
 <META name=viewport content="width=1024, initial-scale=1">
 <META http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <META HTTP-EQUIV="Content-language" CONTENT="tr">
 <link href="shift.css" rel="stylesheet"> 
 <link rel="stylesheet" href="bootstrap.css">
 <link rel="stylesheet" href="product.css">
 </head>
 <body>
 <div id="confirmForm"> </div> 
 </body>
</html>

It doesn't work, what should I change?

Answer*

Draft saved
Draft discarded
Cancel

default

AltStyle によって変換されたページ (->オリジナル) /