How to maintain what the user key in after alert box appear?

Discussion in 'PHP' started by anisFarim, Aug 9, 2011.

  1. #1
    How I want maintain what the user key in after alert box appear; window.alert('No rujukan tidak dijumpai'). Please help me.

    
    <?php session_start(); ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    
    <html>
    <head>
    </head>
    
    <body>
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    	<td>
    <p class="title"><b>PENGESAHAN PENDAFTARAN</b></p>
    <div class="content">
    
    <?php
    if(isset($_POST['seterusnya']))
    {
    	$template = $_POST['template'];
    	$no_rujukan = $_POST['no_rujukan'];
    	
    	if($template == 'template_perlembagaan')
    	{
    		echo "<script language='Javascript'>navigate('semak.php')</script>";
    		exit();
    	}
    	
    	if($template == 'template_sendiri')
    	{
    		include('../config/conn_db.php');
    	
    	$result = mysql_query("SELECT no_rujukan FROM semakan_kaunter WHERE no_rujukan = '$no_rujukan'")
    		or die ("No Rujukan tidak jumpa");
    		
    		$matched = mysql_fetch_array($result);
    		
    		if($matched){
    				echo "<script language='Javascript'>navigate('semak.php')</script>";
    				exit();
    				}
    				
    				else{
    				echo("<SCRIPT LANGUAGE='JavaScript'>
    				window.alert('No rujukan tidak dijumpai')
    				</SCRIPT>");
    				}	
    	}	
    }
    ?>
    		  
        <form id="form1" name="form1" method="post" action="">
    		  
    		  <table id="t1" width="356" border="0">
                <tr>
                  <td colspan="3"><strong>Pilihan Perlembagaan</strong></td>
                </tr>
                
                <tr>
                  <td colspan="3">
                      	<input type="radio" name="template" value="template_perlembagaan" />
                      	Template Perlembagaan
                    	<br />
                    
                      	<input type="radio" name="template" value="template_sendiri" />
                      	Perlembagaan Sendiri
                    	<br /></td>
                </tr>
    
                <tr>
                  <td width="20">&nbsp;</td>
                  <td colspan="2">Nombor Rujukan Semakan:                 
                    <input type="text" name="no_rujukan" id="textfield" /></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td width="127">&nbsp;</td>
                  <td width="198">&nbsp;</td>
                </tr>
                <tr align="right">
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td><input type="submit" name="seterusnya" value="Seterusnya" /></td>
                </tr>
                <tr align="right">
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td><label></label></td>
                </tr>
              </table>    
              <br/>
        </form>	
                  </div>
    	</td>
    </tr>
    </table>
    
    </body>
    </html>
    
    
    PHP:

     
    anisFarim, Aug 9, 2011 IP
  2. HungryMinds

    HungryMinds Active Member

    Messages:
    216
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    63
    #2
    Hi,
    You want to print something after showing alert box? Is alert box working with this code?
     
    HungryMinds, Aug 9, 2011 IP
  3. anisFarim

    anisFarim Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi.. HungryMinds.
    yes. it working. but after i click ok at alert box, the value that i key in at the radio button and text field missing. i want they still with the value i key in before. Can?
     
    anisFarim, Aug 9, 2011 IP
  4. Thorlax402

    Thorlax402 Member

    Messages:
    194
    Likes Received:
    2
    Best Answers:
    5
    Trophy Points:
    40
    #4
    From the looks of this, the alert box should be popping up before you would normally get the chance the click on any radio buttons or fill in the text box. Since there seems to be no default values or selections for the inputs then there shouldn't be anything to save.
     
    Thorlax402, Aug 9, 2011 IP