Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > สอบถามเรื่อง การส่ง post ข้อมูล form ทั้งหมด แบบ ajax ด้วยคำสั่ง serialize



 

สอบถามเรื่อง การส่ง post ข้อมูล form ทั้งหมด แบบ ajax ด้วยคำสั่ง serialize

 



Topic : 106900



โพสกระทู้ ( 586 )
บทความ ( 0 )



สถานะออฟไลน์




Code (PHP)
<?php $title="Change Hotel Backend B2C , B2B System";
include("header.php");
check_position("OPERATION");
include("fetch_data_profile.php");
$r=profile_hotel($_REQUEST);
?>

        <div class="header">            
            <h1 class="page-title">Change Hotel <?php $r["hotel_name1"]." - ".$r["CountryName"] ." - ".$r["CityName"];?></h1>
        </div>
        
        <ul class="breadcrumb">
            <li><a href="home.php">Home</a> <span class="divider">/</span></li>
            <li class="active">Product <span class="divider">/</span></li>
            <li class="active">Hotel</li>
        </ul>

        <div class="container-fluid">
            <div class="row-fluid">
                    
				<div class="btn-toolbar">   
				  <div class="btn-group">
				  </div>
				</div>

				<div class="well">
					<ul class="nav nav-tabs">
					  <li class="active"><a href="#home" data-toggle="tab">Edit</a></li>
					</ul>

					<div id="myTabContent" class="tab-content">

					  <div class="tab-pane active in" id="home">
						<form id="tab">
							<label>Service Id</label>
							<input type="text" id="service_id" value="<?php echo $r["service_id"];?>" readonly>							
							<label>Service Code</label>
							<label class="required" id="service_code_required"></label>
							<input type="text" id="service_code" value="<?php echo $r["service_code"];?>" >		
							<label>Hotel Name</label>
							<label class="required" id="hotel_name1_required"></label>
							<input type="text" id="hotel_name1" value="<?php echo $r["hotel_name1"];?>" >	
							<label>Address</label>
							<label class="required" id="address1_required"></label>
							<input type="text" id="address1" value="<?php echo $r["address1"];?>" >
							<label>City Code</label>
							<label class="required" id="CityCode_required"></label>
							<input type="text" id="CityCode" value="<?php echo $r["CityCode"];?>" >
							<label>City Code Topax</label>
							<label class="required" id="CityCodeTopax_required"></label>
							<input type="text" id="CityCodeTopax" value="<?php echo $r["CityCodeTopax"];?>" >
							<label>City Name</label>
							<label class="required" id="CityName_required"></label>
							<input type="text" id="CityName" value="<?php echo $r["CityName"];?>" >
							<label>Postal</label>
							<label class="required" id="postal_required"></label>
							<input type="text" id="postal" value="<?php echo $r["postal"];?>" >
							<label>Country Code</label>
							<label class="required" id="CountryCode_required"></label>
							<input type="text" id="CountryCode" value="<?php echo $r["CountryCode"];?>" >
							<label>Country Name</label>
							<label class="required" id="CountryName_required"></label>
							<select name="CountryName" id="CountryName">
								<?php select_country_levelpriv($_COOKIE["id_user"],$r["CountryName"]);?>
							</select>
							<label>Hotel Full Description</label>
							<label class="required" id="hotel_full_desc_required"></label>
							<input type="text" id="hotel_full_desc" value="<?php echo $r["hotel_full_desc"];?>" >
							<label>Hotel Room Description</label>
							<label class="required" id="hotel_room_desc_required"></label>
							<input type="text" id="hotel_room_desc" value="<?php echo $r["hotel_room_desc"];?>" >
							<label>Hotel Map Description</label>
							<label class="required" id="hotel_map_desc_required"></label>
							<input type="text" id="hotel_map_desc" value="<?php echo $r["hotel_map_desc"];?>" >
							<label>Thumbnail Picture</label>
							<img src="<?php $r["thumbnail_picture"];?>"></img>
							<input type="file" id="thumbnail_picture">
							<label>Hotel Picture</label>
							<img src="<?php $r["hotel_hotel_picture"];?>"></img>
							<input type="file" id="hotel_hotel_picture">
							<label>Hotel Main Picture</label>
							<img src="<?php $r["hotel_main_picture"];?>"></img>
							<input type="file" id="hotel_main_picture">
							<label>Hotel Lobby Picture</label>
							<img src="<?php $r["hotel_lobby_picture"];?>"></img>
							<input type="file" id="hotel_lobby_picture">
							<label>Hotel Building Picture</label>
							<img src="<?php $r["hotel_building_picture"];?>"></img>
							<input type="file" id="hotel_building_picture">
							<label>Hotel Meet Picture</label>
							<img src="<?php $r["hotel_meet_picture"];?>"></img>
							<input type="file" id="hotel_meet_picture">
							<label>Hotel Pool Picture</label>
							<img src="<?php $r["hotel_pool_picture"];?>"></img>
							<input type="file" id="hotel_pool_picture">
							<label>Hotel Room Picture</label>
							<img src="<?php $r["hotel_room_picture"];?>"></img>
							<input type="file" id="hotel_room_picture">
							<label>Hotel Rating</label>
							<select name="tbhotel_rating" id="tbhotel_rating">
								<?php select_hotel_rating($r["tbhotel_rating"],"");?>
							</select>
							<label>Hotel Category</label>
							<select name="tbhotel_category" id="tbhotel_category">
								<?php select_hotel_category($r["tbhotel_category"],"");?>
							</select>
							<label>MapLatitude</label>
							<input type="text" id="MapLatitude" value="<?php echo $r["MapLatitude"];?>" >
							<label>MapLongitude</label>
							<input type="text" id="MapLongitude" value="<?php echo $r["MapLongitude"];?>" >
							<label>Hotel Email</label>
							<input type="text" id="hotel_email" value="<?php echo $r["hotel_email"];?>" >
							<table width="100%">
							<label>Facilities & Services : <input type="checkbox" id="checkAll">Check All</label>
							<?php 
							$sql=search_facilities();
							$query=mysql_query($sql);
							$count=0;
							while($rx=mysql_fetch_array($query)){
								$sql_sel="select `$rx[COLUMN_NAME]` from hotels where service_id='".$r["service_id"]."' ";
								$query_sel=mysql_query($sql_sel);
								$r_sel=mysql_fetch_array($query_sel);?>
								<?php if($count%3==0){?>
								<tr >
								<?php }?>
									<td>
										<input type="checkbox" id="<?php echo "check[".$count++."]";?>" <?php if($r_sel[$rx["COLUMN_NAME"]]==1){ echo "checked";}?>><?php echo $rx["COLUMN_NAME"];?>
									</td>
								<?php if($count%3==0){?>
								</tr>
								<?php }?>
							<?php
							}
							?>
							</table>
							<input type="hidden" id="count" value="<?php echo $count;?>">
							
							<BR>
							<a href="#mySave" data-toggle="modal" class="btn btn-primary" id="submit"><i class="icon-save"></i> Save</a>
							<a href="#mySave" data-toggle="modal" class="btn btn-primary" id="submit_con"><i class="icon-save"></i> Save & Continue Edit</a>
							<a href="#mySave" data-toggle="modal" class="btn btn-primary" id="con"><i class="icon-save"></i> Not Save & Continue Search</a>
						</form>
					   </div>				
			</div>

		</div>
		
<form id='saveMenu' method='POST' action='hotel_config.php' >
	<input type='hidden' id='service_id' name="service_id" value='<?php echo $_REQUEST["service_id"];?>'>
	<input type='hidden' id='hotel_name1' name="hotel_name1" value='<?php echo $_REQUEST["hotel_name1"];?>'>
	<input type='hidden' id='service_code' name="service_code" value='<?php echo $_REQUEST["service_code"];?>'>
	<input type='hidden' id='CityCodeTopax' name="CityCodeTopax" value='<?php echo $_REQUEST["CityCodeTopax"];?>'>
	<input type='hidden' id='CountryName' name="CountryName" value='<?php echo $_REQUEST["CountryName"];?>'>
</form>

<?php include("footer.php");?>




Code (JavaScript)
$("#submit").click(function(){
		service_code=$("#service_code").val();
		hotel_name1=$("#hotel_name1").val();
		address1=$("#address1").val();
		CityCode=$("#CityCode").val();
		CityCodeTopax=$("#CityCodeTopax").val();
		CityName=$("#CityName").val();
		postal=$("#postal").val();
		CountryCode=$("#CountryCode").val();
		hotel_full_desc=$("#hotel_full_desc").val();
		hotel_room_desc=$("#hotel_room_desc").val();
		hotel_map_desc=$("#hotel_map_desc").val();
		count=$("#hotel_map_desc").val();

		if(service_code==""){
			check_service_code=0;
			$("#service_code_required").html('<span>* This is a required field<span>');
		}else{
			check_service_code=1;
			$("#service_code_required").html('<span><span>');
		}

		if(hotel_name1==""){
			check_hotel_name1=0;
			$("#hotel_name1_required").html('<span>* This is a required field<span>');
		}else{
			check_hotel_name1=1;
			$("#hotel_name1_required").html('<span><span>');
		}

		if(address1==""){
			check_address1=0;
			$("#address1_required").html('<span>* This is a required field<span>');
		}else{
			check_address1=1;
			$("#address1_required").html('<span><span>');
		}

		if(CityCode==""){
			check_CityCode=0;
			$("#CityCode_required").html('<span>* This is a required field<span>');
		}else{
			check_CityCode=1;
			$("#CityCode_required").html('<span><span>');
		}

		if(CityCodeTopax==""){
			check_CityCodeTopax=0;
			$("#CityCodeTopax_required").html('<span>* This is a required field<span>');
		}else{
			check_CityCodeTopax=1;
			$("#CityCodeTopax_required").html('<span><span>');
		}

		if(CityName==""){
			check_CityName=0;
			$("#CityName_required").html('<span>* This is a required field<span>');
		}else{
			check_CityName=1;
			$("#CityName_required").html('<span><span>');
		}

		if(postal==""){
			check_postal=0;
			$("#postal_required").html('<span>* This is a required field<span>');
		}else{
			check_postal=1;
			$("#postal_required").html('<span><span>');
		}

		if(CountryCode==""){
			check_CountryCode=0;
			$("#CountryCode_required").html('<span>* This is a required field<span>');
		}else{
			check_CountryCode=1;
			$("#CountryCode_required").html('<span><span>');
		}

		if(hotel_full_desc==""){
			check_hotel_full_desc=0;
			$("#hotel_full_desc_required").html('<span>* This is a required field<span>');
		}else{
			check_hotel_full_desc=1;
			$("#hotel_full_desc_required").html('<span><span>');
		}

		if(hotel_room_desc==""){
			check_hotel_room_desc=0;
			$("#hotel_room_desc_required").html('<span>* This is a required field<span>');
		}else{
			check_hotel_room_desc=1;
			$("#hotel_room_desc_required").html('<span><span>');
		}

		if(hotel_map_desc==""){
			check_hotel_map_desc=0;
			$("#hotel_map_desc_required").html('<span>* This is a required field<span>');
		}else{
			check_hotel_map_desc=1;
			$("#hotel_map_desc_required").html('<span><span>');
		}

		  if(check_service_code==1 && check_hotel_name1==1 && check_address1==1 && check_CityCode==1 && check_CityCodeTopax==1 && check_CityName==1 && check_postal==1 && check_CountryCode==1 && check_hotel_full_desc==1 && check_hotel_room_desc==1 && check_hotel_map_desc==1 ){
			  form = $("#tab").serialize();
			  alert(form);
			  if(confirm("Confirm to update xml")){				   
				   $.ajax({
					   type: "POST",
					   url: "do_query_hotel.php",
					   data: form,

					   success: function(data){
						   alert(data);
						   
							if($.trim(response)=='success'){

								alert("Update Xml already.");
								$("#saveMenu").submit();
								
							}else{

								alert("Cann't update Xml!");
								$("#saveMenu").submit();
								
							}
					   }

					 });
			  }
		  }
	});


1. ที่ผมต้องการคือ โยนค่า จาก input ทั้งหมด เข้าไป insert ในไฟล์ do_query_hotel.php ด้วยคำสั่ง serialize
แต่ปรากฎว่าผมโยนค่าได้แค่ดังนี้ตามรูป
ผม alert(form) ได้ข้อมูลดังนี้

test

2. แล้วตัวแปร ที่มาจากการแนบรูป ผมจะโยนเข้าไปในไฟล์ do_query_hotel.php ได้ไหม๊ครับ อย่างไร

รบกวนช่วยชี้แนะด้วยครับ



Tag : PHP, Ajax, jQuery







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-03-14 14:08:49 By : nut_ch31 View : 1116 Reply : 2
 

 

No. 1



โพสกระทู้ ( 586 )
บทความ ( 0 )



สถานะออฟไลน์


ข้อ 1 รู้ล่ะ ต้องใส่ input name="" <<< ใส่ name ให้แต่ละ input ลืมสะงั้น Y Y






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-14 14:15:10 By : nut_ch31
 


 

No. 2



โพสกระทู้ ( 1,994 )
บทความ ( 10 )



สถานะออฟไลน์
Facebook Blogger

การอัพไฟล์ต้องผ่าน iframe ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-14 16:01:00 By : {Cyberman}
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามเรื่อง การส่ง post ข้อมูล form ทั้งหมด แบบ ajax ด้วยคำสั่ง serialize
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่