DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login

Depending/Chain Combo box viewed as selected

By: Manoj | 19 Sep 2008 11:12 pm

 Hi every one,

I have used the followinng code for chain/depending combo box.
I want to see the values of every combo box as the selected items.
But I'm unable to do that. Can anyone can help me to do that?

I have heard that using AJAX it can be solved. But I have not any such
type of code. So, you can help me also by giving a such types of AJAX code.

For better understanding, I have attached the database file here which I have used.

Please help me.

Thank you.

//////////// ///////// ///////// ///////// ///////// ///////// ///
<html>
<head>

<title>IBTRA Accounts :: Accounts Entry</title>

<style type="text/css" >
<!--
.ListText {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9pt;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    font-variant: normal;
    color: #3366CC;
}
.Text {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 9pt;
    font-style: normal;
    font-weight: bold;
    font-variant: normal;
    color: #003366;
}
.BodyText {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 10pt;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    font-variant: normal;
}
.style1 {font-size: 12pt}
.style3 {font-family: Arial, Helvetica, sans-serif; font-size: 11pt; font-style: normal; line-height: normal; font-weight: normal; font-variant: normal; color: #3366CC; }
.warning {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 8pt;
    font-style: normal;
    font-weight: bold;
    color: #FF0000;
}
-->
</style>
</head>

<script language="javascrip t" type="text/javascri pt">

function setfocus()
{
        document.form. Prog.focus( );
}   

function load_fun()
{
var i=document.form. Prog.value;
var j=i;
location.href= "?i="+j;
}
//////////// ///////// ///////// //
function load()
{
var a=document.form. ProgramId. value;
var c=a;
location.href= "?a="+c;
}
//////////// ///////// /////////
function acc_load()
{
var x=document.form. Program.value;
var y=x;
location.href= "?x="+y;
}
//////////// ///////// ///////// ///////
function contra_value( )
{
    if(document. form.txtAmount. value=='0' )
    {
        alert("Sorry !!! \nThe amount field cannot be zero (0) ! !! !!!");   
        document.getElement ById("txtContraA mount").value ="Wrong input";
        document.form. txtAmount. focus();
    }
    else
        document.getElement ById("txtContraA mount").value = document.getElement ById("txtAmount" ).value ;   
}
//////////// ///////// ///////// ///////// /
function validity()
{
    var valid=1;

    if(document. form.combo_ accounts_ head.value= ="" || document.form. particulars. value==""
    || document.form. txtAmount. value=="" || document.form. txtOnAccountOf. value==""
    || document.form. txtContraAmount. value=="Wrong input" || document.form. txtContraAmount. value=="" )
    { valid=0;   
    alert("Sorry! !!\n\nPlease fill up all the fields ! !! !!!\n\n");
     document.form. particulars. focus();
    }

    if(document. form.txtContraAm ount.value! =document. form.txtAmount. value)
    { valid=0;   
    alert("Sorry! !!\n\nAmount and contra amount is not same ! !! !!!\n\n");
     document.form. txtAmount. focus();
    }

    var digits = "0123456789" ;
    for (var i = 0; i < document.form. txtAmount. value.length; i++)
      {
        temp = document.form. txtAmount. value.substring( i, i+1)

        if (digits.indexOf( temp) == -1 && document.form. txtAmount. value != "")
        { valid=0;
             alert("Sorry! !!\n\nAmount must be positive numeric value ! !! !!!\n\n");
          document.form. txtAmount. focus();
          break;
        }
      }
   
    if(valid=='0' )
        return false;
    else
        return true;
}
//////////// ///////// ///////// ////
</script>

<?php
$gl_head_type= $_GET['i' ];
$_SESSION['gl_ head_type' ]="$gl_head_ type";

$id=$_GET['a' ];
$_SESSION['id' ]="$id";

$sub_gl_id=$ _GET['x'] ;
$_SESSION['sub_ gl_id']=" $sub_gl_id" ;
?>

<body>
<div align="center" ></div>
<form name="form" method="post" onSubmit="return validity()" action="">
  <span class="warning" ><br>
  </span>
  <div align="center" class="warning" ><?php echo $warning?><br>
    <br>
  </div>
  <table width="60%"  border="1" align="center" cellpadding= "1" cellspacing= "1">
    <tr>
      <td><table width="98%" border="0" align="center" cellpadding= "0" cellspacing= "4">
        <tr>
          <td rowspan="2" align="center" valign="middle" ><div align="center" class="Text" >
              <div align="center" >              </div>
          </div>
            <div align="right" class="BodyText" >
                <div align="left" >
                  <object classid="clsid: D27CDB6E- AE6D-11cf- 96B8-44455354000 0" codebase="http://download. macromedia. com/pub/shockwav e/cabs/flash/ swflash.cab# version=6, 0,29,0" width="60" height="60">
                    <param name="movie" value="images/ ibbl.swf" >
                    <param name=quality value=high>
                    <embed src="images/ ibbl.swf" quality=high pluginspage= "http://www.macromed ia.com/shockwave /download/ index.cgi? P1_Prod_Version= ShockwaveFlash" type="application/ x-shockwave- flash" width="60" height="60"> </embed>
                  </object>
                </div>
            </div>           
            </div></td>
          <td colspan="5"> <div align="center" class="Text" ><span class="style1" >Islami Bank Bangladesh Limited</span> <br>
                <span class="style3" >IBTRA Branch </span></div> </td>
          <td width="79">< div align="right" class="BodyText" >F-4/F-5< /div></td>
        </tr>
        <tr>
          <td>&nbsp;</ td>
          <td>&nbsp;</ td>
          <td>&nbsp;</ td>
          <td colspan="3"> <div align="right" class="BodyText" >Date:
            <script language="JavaScrip t"  src="popcalendar. js"type=" text/JavaScript" >
            </script>

            <input name="text_date" type="text" readonly="" value="<?php echo date ("d-m-Y")?>" id="text_date" size="10" align="right" >
            <img align="absbottom" src="images/ date.gif"  height="20" width="34" onclick='popUpCalen dar(this, form.text_ date, "dd-mm-yyyy" )' title="Press here to select date.">

               </div></td>
          </tr>
        <tr>
          <td width="79" bordercolor= "#000000" bgcolor="#DFF0FF" class="Text" ><div align="center" ><strong> Asset/Liability< /strong>< /div></td>
          <td width="65" bordercolor= "#000000" bgcolor="#DFF0FF" class="Text" ><div align="center" ><strong> GL Head</strong> </div></td>
          <td width="74" bordercolor= "#000000" bgcolor="#DFF0FF" class="Text" ><div align="center" ><strong> GL Sub Head</strong> </div></td>
          <td width="82" bordercolor= "#000000" bgcolor="#DFF0FF" class="Text" ><div align="center" ><strong> Account Name </strong></div> </td>
          <td width="90" bordercolor= "#000000" bgcolor="#DFF0FF" class="Text" >              <p align="center" >Particulars< /p></td>
          <td width="73" bgcolor="#DFF0FF" class="Text" ><div align="center" >D/C</div> </td>
          <td bgcolor="#DFF0FF" class="Text" ><div align="center" >Amount</ div></td>
        </tr>
        <tr>
          <td width="79" bordercolor= "#000000" class="Text" >
            <select name="Prog" class="ListText" id="Prog" onChange='load_ fun()' title="Select asset or liability">
              <?php
                $sql3="select * from head_gl group by gl_head_type" ;
                $sqlres3=mysql_ query($sql3) ;

                echo "<OPTION value=''>Select< /OPTION>" ;
                while($row3= mysql_fetch_ array($sqlres3) )
                {
                        echo "<OPTION value=".$row3[ gl_head_type] .">".$row3[ gl_head_type] ."</OPTION> ";
                } // while               
                echo "</SELECT>";
              ?>
          </td>
          <td width="65" bordercolor= "#000000" class="Text" >
            <select name="ProgramId" class="ListText" onChange='load( )' title="Select one of the GL head...">
            <?php
            echo "<OPTION value=''>Select< /OPTION>" ;
            $sql="select * from head_gl where gl_head_type= '".$gl_head_ type."' order by gl_code_no ASC";
            $sqlres=mysql_ query($sql) ;
            while($row=mysql_ fetch_array( $sqlres))
            {
                            echo "<option value=".$row[ id].">".$ row[gl_head] ."</option> ";
            } echo "</SELECT>";
            ?>
             </td>
              <td width="74" bordercolor= "#000000" class="Text" >
            <select name="Program" class="ListText" onChange='acc_ load()' title="Select one of the GL sub head...">
              <option value="">Select< /option>
              <?php
            $sql1="select * from head_sub_gl where gl_id='".$id. "' group by sub_gl_head" ;
            $sqlres1=mysql_ query($sql1) ;
            while($row1= mysql_fetch_ array($sqlres1) )
            {
                 echo "<option value=".$row1[ sub_gl_id] .">".$row1[ sub_gl_head] ."</option> ";
            } echo "</select>";
            ?>
          </td>
          <td bordercolor= "#000000" class="Text" ><select name="combo_ accounts_ head" class="ListText" id="combo_accounts_ head"  title="Select one of the account name...">
              <option value="">Select< /option>
              <?php
                $sql2="select * from accounts_name where gl_sub_head_ id='".$sub_ gl_id."' order by account_name ASC";
                $sqlres2=mysql_ query($sql2) ;
                while($row2= mysql_fetch_ array($sqlres2) )
                {
                echo "<option value=".$row2[ a_id].">" .$row2[account_ name]."</ option>";
                } echo "</select>";
                ?>
          </td>
          <td bordercolor= "#000000" class="Text" ><input name="particulars" type="text" id="particulars" size="15" maxlength="50" ></td>
          <td class="ListText" ><select name="debit_ credit" id="debit_credit" >
            <option value="Debit" >Debit</option>
            <option value="Credit" >Credit</ option>
          </select></td>
          <td class="ListText" ><input name="txtAmount" type="text" id="txtAmount" style="text- align:right" value="0" size="8" maxlength="20" ></td>
        </tr>
        <tr class="BodyText" >
          <td colspan="7"> On Account of &nbsp;
            <input name="txtOnAccountO f" type="text" id="txtOnAccountOf2 " size="73" maxlength="200" ></td>
          </tr>
        <tr class="BodyText" >
          <td colspan="7"> Contra Account
            <input name="txtContra" readonly="" type="text" id="txtContra" value="Cash in hand" size="15" maxlength="20" > &nbsp;
            <input name="txtContraAmou nt" onFocus='contra_ value()' type="text" id="txtContraAmount " style="text- align:right" size="10" maxlength="20" ></td>
          </tr>
        <tr>
          <td colspan="7"> <div align="right" >
              <input name="btn_submit" type="submit" id="btn_submit" value="Submit" >
              <input type="reset" name="Submit2" value="Reset" >
          </div></td>
        </tr>
      </table></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
</body>
</html>

Comments

No Comments Posted for this Article.

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move