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 > class create input (text , password , button , reset , submit , textarea , select)



 

class create input (text , password , button , reset , submit , textarea , select)

 



Topic : 095865



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



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




ผมทำเอาไว้ใช้งานเลยเอามาแบ่งเผื่อ มีใครต้องการ
Code (PHP)
<html><head><title></title></head><body>
<?php
/*	index.php
	create text, password, button, submit, reset, textarea, select, radio, checkbox	
        support javascript 
        ทำงานผ่าน array การเรียงค่าเช็กจากใน array
	*/
$param = array( 	'query_sent' => array(
														'type' => array('checkbox','select' , 'radio' , 'button' , 'select' , 'text'), //input type
														'textid' => array('001' , '002' , '003' , '004' , '005' , '006'), //id name
														//	'copy' => false , // option
														'class' => array('001','002' , '003' , '004' , '005' , '006'), //class
														'val' => array('00001','00002' , '00003' , '00004' ,'00005' , '00006'), //value  input 
														'option_select' => array("",array('test01','test02'),"","",array('test03','test04'),""), //option input select
														'onclick' => array('','','',array('sent' , array('002','001')),"","")//สำหรับส่งตัวแปลไปที่ javascript array('sent' , array('002','001')) sentคือชื่อฟังชั้น array('002','001') คือตัวแปลที่ฟั้งชั้นส่งไป
												)
											);
					$input = new createinput($param['query_sent']);
					$input->queryinput(999);//ถ้า option = 999 จะสร้าง input ออกมาทั้งหมด
					echo "<br />";
					$input->queryinput(0);//ถ้า option = 0 จะสร้าง input checkbox ออกมา
					echo "<br />";
					$input->queryinput(2);//ถ้า option = 2 จะสร้าง input radio ออกมา
					echo "<br />";
					$input->queryinput(5);//ถ้า option = 5 จะสร้าง input radio ออกมา
				?>
</body></html>


Code (PHP)
<?php //class.php
class createinput{
		var $template = ""; //ตัวแปร input
		var $textid = ""; //คัวแปร id และ namr
		var $num = ""; //ตัวแปร สำหรับการ query input ทั้งหมด
		var $type = ""; // ตัวแปร type ของ input
		var $classinput = ""; // ตัวแปร class
		var $option_select = ""; // ตัวแปร Option ของ select
		var $onclick = ""; // onclick สำหรับ javascript
		var $valuesent = ""; // ตัวแปร value 
		var $params;
		public function __construct($param) 
		{	$this->params = $param;
		}
		public function queryinput($query)
		{	
				$param = $this->params;
				$this->type = $param['type'];
				$this->textid = $param['textid'];
				$this->classinput =  $param['class'];
				$this->ovalue = $param['val'];
				$this->option_select = $param['option_select'];
				$this->onclick = $param['onclick'];
				$this->template = "";
				$this->num = count($this->type)-1;
				if($query == 999)
				{	for($i=0;$i<=$this->num;$i++) //loob create input
					{	switch($this->type[$i])
						{
							case 'text' :
							case 'password' :
							case 'submit' :
							case 'button' :
							case 'reset' :
							case 'checkbox' :
							case 'radio':
							if($this->onclick[$i] != ""){	
								foreach($this->onclick[$i][1] as $key => $value)
								{	if($key == 0){
										$this->valuesent .=	$value;}
									else{	$this->valuesent .=	",".$value;}
								}
								$this->template .= "<input onclick=".$this->onclick[$i][0]."(".$this->valuesent."); type=".$this->type[$i]." id=".$this->textid[$i]." name=".$this->textid[$i]." class=".$this->classinput[$i]." value=".$this->ovalue[$i]." />";
							}
							else{
								$this->template .= "<input type=".$this->type[$i]." id=".$this->textid[$i]." name=".$this->textid[$i]." class=".$this->classinput[$i]." value=".$this->ovalue[$i]." />";
							}
							break;
							case 'textarea' :
								switch($this->textid[(int)$query])
								{
									case 'detailth' :
										$this->template .= "<".$this->type[$i]." id=".$this->textid[$i]." name=".$this->textid[$i]." class=".$this->classinput[$i].">".$this->ovalue[$i]."</textarea>";
									break;
									case 'detailen' :
							/*		if($param['copy'] == true)
									{
										$this->template .= "<img id='copy' src='images/text-copy-txteditor.jpg' title='Copy text  language :: Thai to English' onclick='gettext();' style='cursor:pointer;' />";
									}	*/
										$this->template .= "<".$this->type[$i]." id=".$this->textid[$i]." name=".$this->textid[$i]." class=".$this->classinput[$i].">".$this->ovalue[$i]."</textarea>";
									break;
									default :
										$this->template .= "<".$this->type[$i]." id=".$this->textid[$i]." name=".$this->textid[$i]." class=".$this->classinput[$i].">".$this->ovalue[$i]."</textarea>";
									break;
								}
							break;
							case 'select' :
								$this->template .= "<".$this->type[$i]." id=".$this->textid[$i]." name=".$this->textid[$i].">";
								foreach($this->option_select[$i] as $key => $value)
								{
									$this->template .= "<option id=".$key.">".$value."</option>";
								}
								$this->tamplate .= "</".$this->type[$i].">";
							break;					
						}
					}//end loob create input
				}
				else if($query != 999)
				{	switch($this->type[(int)$query])
					{	case 'text' :
						case 'password' :
						case 'submit' :
						case 'button' :
						case 'reset' :
						case 'checkbox' :
						case 'radio':
						//new create input
							if($this->onclick[(int)$query] != ""){
								foreach($this->onclick[(int)$query][1] as $key => $value)
								{	if($key == 0){
										$this->valuesent .=	$value;}
									else{	$this->valuesent .=	",".$value;}
								}
								$this->template .= "<input onclick=".$this->onclick[(int)$query][0]."(".$this->valuesent."); type=".$this->type[(int)$query]." id=".$this->textid[(int)$query]." name=".$this->textid[(int)$query]." class=".$this->classinput[(int)$query]." value=".$this->ovalue[(int)$query]." />";
							}else{
								$this->template .= "<input type=".$this->type[(int)$query]." id=".$this->textid[(int)$query]." name=".$this->textid[(int)$query]." class=".$this->classinput[(int)$query]." value=".$this->ovalue[(int)$query]." />";
							}
						break;
						case 'textarea' :
							switch($this->textid[(int)$query])
							{	case 'detailth' :
									$this->template .= "<".$this->type[(int)$query]." id=".$this->textid[(int)$query]." name=".$this->textid[(int)$query]." class=".$this->classinput[(int)$query].">".$this->ovalue[$i]."</textarea>";
								break;
								case 'detailen' :
						/*		if($param['copy'] == true)
								{
									$this->template .= "<img id='copy' src='images/text-copy-txteditor.jpg' title='Copy text  language :: Thai to English' onclick='gettext();' style='cursor:pointer;' />";
								}		*/
									$this->template .= "<".$this->type[(int)$query]." id=".$this->textid[(int)$query]." name=".$this->textid[(int)$query]." class=".$this->classinput[(int)$query].">".$this->ovalue[$i]."</textarea>";
								break;
							}
						break;
						case 'select' :
							$this->template .= "<".$this->type[(int)$query]." id=".$this->textid[(int)$query]." name=".$this->textid[(int)$query].">";
							foreach($this->option_select[(int)$query] as $key => $value)
							{
								$this->template .= "<option id=".$key.">".$value."</option>";
							}
							$this->tamplate .= "</".$this->type[(int)$query].">";
						break;
					}//end create input 
				}
				echo $this->template; //return input
		}
}
?>




Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-05-30 11:40:28 By : bankza009 View : 910 Reply : 3
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

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

จัดไปครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 12:35:14 By : mr.win
 


 

No. 2



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

สมาชิกที่ใส่เสื้อไทยครีเอท

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

Error
Fatal error: Class 'createinput' not found in C:\AppServ\www\intern\index.php on line 18


ต้องแก้ยังไงคะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 12:45:20 By : gosling
 

 

No. 3



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



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


ตอบความคิดเห็นที่ : 2 เขียนโดย : gosling เมื่อวันที่ 2013-05-30 12:45:20
รายละเอียดของการตอบ ::
ต้อง include(class.php);

ไปในไฟล์ index.php ด้วยครับ



ประวัติการแก้ไข
2013-05-30 12:50:15
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-05-30 12:49:31 By : bankza009
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : class create input (text , password , button , reset , submit , textarea , select)
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 00
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 อัตราราคา คลิกที่นี่