Results 1 to 13 of 13

Thread: auto bila tekan enter dalam php

  1. #1
    Join Date
    Sep 2007
    Location
    malaysia
    Posts
    7
    Rep Power
    0

    auto bila tekan enter dalam php

    Sekarang ni sy dah buat, tp bila tekan enter takde apa2 yg keluar. tp kalau tekan button submit baru arahan tu kelaur.

    mcm mana nak buat dalam php apabila user input kemudian enter automatik akan paparkan maklumat yg kite nak?

  2. #2
    Join Date
    Sep 2007
    Location
    Wo|2l|] 0f my 0\/\/|\|
    Posts
    40
    Rep Power
    0
    haha iam the 1st 1 to reply ur thread again...

    ahem...ok what is the input type u requesting for input? izzit "text" or "textarea"?

    if u use "text" type the form will be sumitted auto on enter else if u using "textarea" u need to place javascript to catch the action, eg:

    <textarea onkeypress="if (event.keyCode == 13) {this.form.submit();}">

  3. #3
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    275
    bagi full code la..
    senang orang nak trace kat mana tak betul.

    (selalunya by default, samada klik atau tekan enter.. mmg 'send' output)

  4. #4
    Join Date
    Sep 2007
    Location
    malaysia
    Posts
    7
    Rep Power
    0
    kenzi7, i guna type=text. tp tak auto pun bila enter... confuse lah.... anybody can help me????

  5. #5
    Join Date
    Sep 2007
    Location
    malaysia
    Posts
    7
    Rep Power
    0
    ini full code yg sy dh buat.

    HTML Code:
    <script language="JavaScript" type="text/JavaScript">
    
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
     //  if (restore) "wartade.php"=0;
    }
    
    </script>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Pertanyaan Status Pinjaman</title>
    </head>
    <body bgcolor="#0066FF" topmargin="0">
    <form name="f1" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
      <p align="center"> </p>
      <p align="center">&nbsp;</p>
      <h2 align="center"> 
        <p align="center"><font color="#FFFF00" size="2" face="Arial, Helvetica, sans-serif">Semakan 
          Secara Online untuk Status Pinjaman Kenderaan dan <br>
          Pinjaman Komputer Oleh Kakitangan Kerajaan Negeri Sembilan</font></p>
      </h2>
      <div align="center"> 
        <table width="499" align="center">
          <tr> 
            <td width="378"><div align="center"> 
                <p><font color="#00FF00" size="2" face="Arial, Helvetica, sans-serif">Masukkan 
                  No. Kad Pengenalan :</font><font size="2"> </font><font size="3">
    <input name="kp" type="text" >
                  </font></p>
                </div></td>
    			
            <td width="89"></p><font size="3"> <font size="3"> 
              <input name="Cari" type="submit" value="Cari" style="border: 1px solid #C0C0C0; padding: 1px">
              </font> </font>
           <td width="16"> <div align="left"><font size="3"> &nbsp; </font> <font size="3">&nbsp;</p> 
                </font></div></tr><p></p>
        </table>
        <font size="3"> </font></h4> <font size="3"> </font> </div>
    </form>
    </body>
    </html>
    
    
    
    <?php
    
    if (isset($_POST['Cari']) && $_POST['Cari']=='Cari') 
    {
    require_once ('mysql_connect.php'); 
      
       $kp=($_POST['kp']);
       $query_kp = "SELECT acctype,name,respdesc,status
                       FROM slloan 
    		     	  where paynonewic = upper('" .$kp."')" ;
    	
    	$papar = mysql_query($query_kp);
    	
       
      $line=mysql_fetch_array($papar);
        if ($line != 0 ) {	
       $acctype =$line['acctype'];
       	if ($acctype=1) {
    		$acctype = 'Pinjaman Kenderaan';}
    	if ($acctype=2) {
    		$acctype = 'Pinjaman Komputer';
    	}  
       $nama =$line['name'];
       $respdesc =$line['respdesc'];
       
       $status =$line['status'];
       
       if ($status = 'A'){
          $status ='Belum Disemak DI PTJ';}
       if ($status = 'P'){
        $status ='Disemak DI PTJ';}
    	if ($status = 'V'){
          $status ='Dilulus Oleh Jabatan';}
    	  if ($status = 1){
          $status ='Disemak DI PKN';}
    	  if ($status = 2){
          $status ='Dilulus Oleh PKN';}
    	  if ($status = 3){
          $status ='Perjanjian';}
    	  if ($status = 5){
          $status ='Baucar Dicetak';}
    	  if ($status = 6){
          $status ='Cek Dikeluarkan';}
    	  if ($status = 7){
          $status ='Kad Lejer';}
    	  else{
          $status ='Permohonan Ditolak';}
    	  
    ?>  
      <form name="form1" method="post" action="">
       
      <div align="center">
    	
    	<table border="1" width="60%" id="alamat" cellspacing="0" cellpadding="0" bordercolorlight="#EEEEDD" bordercolordark="#F8F8F1">
    	<tr> <td width="100" align="left" bgcolor="#003366">
    	<p align="left"><font color="#FFFFFF" size="2" face="Arial">&nbsp;Jenis Pinjaman</font></td>
    	<td bgcolor="#CCCCFF" bordercolor="#EEEEDD"><font face="Arial">
    	&nbsp;<?php echo $acctype; ?></font></td> </tr>
    	<tr><td width="100" align="left" bgcolor="#003366">
    			<p align="left"><font color="#FFFFFF" size="2" face="Arial">&nbsp;Nama Peminjam</font></td>
    	<td bgcolor="#CCCCFF" bordercolor="#EEEEDD"><font face="Arial">
    			&nbsp;<?php echo $nama; ?><br>
    			<tr><td width="100" align="left" bgcolor="#003366">
    <p align="left"><font color="#FFFFFF" size="2" face="Arial">&nbsp;Jabatan</font></td>
    
    	<td bgcolor="#CCCCFF" bordercolor="#EEEEDD"><font face="Arial">
    			&nbsp;<?php echo $respdesc; ?>
    	</font></td> 
    			</tr>
    			<tr><td width="100" align="left" bgcolor="#003366">
    <p align="left"><font color="#FFFFFF" size="2" face="Arial">&nbsp;Status</font></td>
    	<td bgcolor="#CCCCFF" bordercolor="#EEEEDD"><font face="Arial">
    			&nbsp;<?php echo $status; ?>
    	</font></td> 
    			</tr>
    		
    		
    </table>
    
    		</tr>	
    		
    	</table>
      </div>
    	<p align="left" style="margin-top: 4px; margin-bottom: 0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       
    	</p><center>
    <?php	
    //unset($_POST['Cari']);
    }
      else {
        echo "<p><b><center> Tiada Maklumat Untuk No Kad Pengenalan ". $kp . "</p></b>" ; 
      }  
    }  
     
    //unset($_POST['Cari']);
    
    ?>

    sy guna database. connection kat fail lain.
    Last edited by mysticmind; 21-09-2007 at 08:46 PM. Reason: ubah supaya nampak code view

  6. #6
    Join Date
    Sep 2007
    Location
    Wo|2l|] 0f my 0\/\/|\|
    Posts
    40
    Rep Power
    0
    <form name="form1" method="post" action="">
    this form (above) is not closed by </form> and there is no submission within this form1. i tried the form u made and submit it "by-enter" and "button" and it submit the form, ofcoz it returns null but the point is the form got submitted with both actions. i tried it using IE n Firefox

    correct me if im wrong

  7. #7
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    275
    Code:
     <form name="form1" method="post" action="">
    Saya rasa ada terlebih kod form nih.
    sebab yang kaat bawah tu macam nak paparkan, so kenapa kena ada FORM lagi kat situ.

    mungkin conflict sebab ada 2 form. (dan macam kenzi kata) form tu juga tidak di tutup </form>

  8. #8
    Join Date
    Oct 2005
    Location
    KLC
    Posts
    91
    Rep Power
    168
    sorry la. mule2 aku try nak betul kan kod ni. tapi tgk2 byk html tags berterabur. pening aku tgk. lepas dah tutup tag '</html>' pun boleh ade code lagi?

    tgk code bawah ni
    </font></div></tr><p></p>
    </table>
    ...mane2 html coder sepatut tahu ape yg silap dlm code ni. byk silap dlm coding html file ni.

    tag form yg last tu boleh buang sebab kat situ cam takde ape2 form element pun. tapi walau tag tu ade, die takde konflik ngan tag form kat atas sebab yg kat atas tu dah ade penutup.

    tapi kan. ape nak sebenar ni? boleh terangkan tak? kalau cursor dlm text input box, dan kite klik enter, form tu akan submit ikut button submit pertama yg ade dlm form tu. contoh, kalau satu form ade 2 sumbit button, button submit pertama yg akan di 'submit' selagi button tu dlm group form yg same.

    cam ne pun, php cume 'server side' scripting. ape2 yg nak kontrol dlm browser utk display, itu kene buat pakai html dan javascript. so, kalau nak kalau user tekan enter mase dlm page tu, itu kene pakai javascript. tgk sini >> Handling Keyboard Shortcuts in JavaScript
    klaatu barada nikto

  9. #9
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    275
    yup.. kod html dia berterabur dengan teruk.
    saya tak rasa dia pandai sangat HTML..
    so saya cuba selesaikan cara senang paham je dulu.
    sila belajar html dengan lebih rajin!

    kalau ikutkan.. orang dah tak pakai table pun.. semua pakai Div dan css

  10. #10
    Join Date
    Sep 2007
    Location
    malaysia
    Posts
    7
    Rep Power
    0
    Terima kasih yg reply thread saya nie. sebenarnye, ni adalah sistem pertama sy yg menggunakan PHP. So, memang sy masih di peringkat belajar lagi untuk coding PHP.

  11. #11
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    275
    bukan php problem lah, tapi..
    HTML kod yang masih kelam kabut.

    Elakkan penggunaan software WYSIWYG , tapi masterkan diri manual coding of HTML.
    that should be better way to be a good programer.

  12. #12
    Join Date
    Oct 2005
    Location
    KLC
    Posts
    91
    Rep Power
    168
    tak jugak. pakai dreamweaver sepatut kod takde sampai gitu. anyway, start from scratch. html dulu. camne page form, dan camne page utk result. gunekan 2 page. dah lame2, dah biase baru la buat satu page. jgn jadik cam aku, kalu buleh sumer bende nak dlm index.php jer. la lala lala
    klaatu barada nikto

  13. #13
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    275
    kalau dah pandai manual.. takde masalah nak pakai DW.
    but most of them, using DW without knowing ENOUGH html.

    yup.. baik asing2kan dulu.. daripada combine 1 page.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Anybody who is using BMC products, please enter!!!
    By akelvin in forum Other Webmaster-related Services and Promotion
    Replies: 0
    Last Post: 10-06-2009, 12:08 PM
  2. Error bila post forum (XOOPS CMS)
    By fuadsyazwan in forum Website Programming
    Replies: 0
    Last Post: 30-10-2007, 11:00 PM
  3. I need help please enter
    By speedman in forum E-Commerce
    Replies: 1
    Last Post: 11-08-2006, 06:59 PM
  4. GatheringWebmasterMalaysia bila yer?????
    By iwanz in forum FeedBack & Suggestion
    Replies: 3
    Last Post: 30-08-2002, 12:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39