Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: CheckboxProblem

  1. #1
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CheckboxProblem

    Hi all..I am coding a form in the process come across various irritating problems..due to which i'm hung..i cant go ahead..plz help anyone.

    the different problems i'll discuss in different posts..so kindly have a look at them..and if possible plz help.

    1)first is the checkbox problem..i want to check the multiple checkboxes at a time and want to update it after revisiting it.
    Iam taking the name as name=type[]..in the form of array..but on checking it the result in the database simply gives the world 'array'.i want multiple checkboxes to be checked and updated simultaneously..
    and the query to insert the checkbox value has to be included along with the query performed to insert data for rest of the form..

    All of the forums i have visited have been of no use..so have a look at it.the coding is given below:

    Quote:
    Originally Posted by
    This is one of the parts of thee form and not the complete form


    Code: ( php )
    <?

    include "dbconnect.php";
    //error_reporting('notice');
    if(isset($_POST['submit']))
    {//handle the form
    $message=NULL;

    $type=$_POST['type'];
    $query ="insert into form
    (type,other,purpose)VALUES('$type','$other','$purp ose');

    $result =mysql_query($query);

    if(!$result){die(mysql_error());}
    else {echo 'Record Inserted';}



    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" ><table width="90%" align=center cellpadding=2 class=medium>
    <tbody>
    <tr>
    <td width="42%"><font color="#333333" size="1"
    face="Verdana, Arial, Helvetica, sans-serif"><br>
    <input type=checkbox name=type[] value=Logo/Brochure>

    Logo/Brochure </font></td>
    <td><font color="#333333" size="1"
    face="Verdana, Arial, Helvetica, sans-serif"><br>
    <input type=checkbox value= Software/Web application development name=type[]>
    Software/Web Application Development</font></td>
    </tr>
    <tr>
    <td width="42%"><font color="#333333" size="1"
    face="Verdana, Arial, Helvetica, sans-serif"><br>
    <input type=checkbox value=CD presentations name=type[]>
    CD presentations</font></td>
    <td><font color="#333333" size="1"
    face="Verdana, Arial, Helvetica, sans-serif"><br>
    <input type=checkbox value=2D/3D animations name=type[]>
    2D/3D animations</font></td>
    </tr>
    <tr>
    <td><font color="#333333" size="1"
    face="Verdana, Arial, Helvetica, sans-serif"><br>

    <input type=checkbox value= Web banner/intro name=type[]>
    Web Banner/Intro</font></td>
    <td><font color="#333333" size="1"
    face="Verdana, Arial, Helvetica, sans-serif"><br>
    <input type=checkbox value=E-learning name=type[]>
    E-learning </font></td>
    </tr>
    <tr>
    <td><p><font color="#333333" size="1"
    face="Verdana, Arial, Helvetica, sans-serif"><br>
    If other, please explain: </font></p></td>
    <td valign=bottom><div align=right><font color="#333333" size="1"
    face="Verdana, Arial, Helvetica, sans-serif">
    <input name="other" type="text" size="50" value="<?php if(isset($_POST['other'])) echo($_POST['other'])?>" >
    </font></div></td>
    </tr>
    </tbody>
    </table></form>


    So this is the code for checkbox...if any have the solution..plz post it

  • #2
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi all..I am coding a form in the process come across various irritating problems..due to which i'm hung..i cant go ahead..plz help anyone.

    the different problems i'll discuss in different posts..so kindly have a look at them..and if possible plz help.

    1)first is the checkbox problem..i want to check the multiple checkboxes at a time and want to update it after revisiting it.
    Iam taking the name as name=type[]..in the form of array..but on checking it the result in the database simply gives the world 'array'.i want multiple checkboxes to be checked and updated simultaneously..
    and the query to insert the checkbox value has to be included along with the query performed to insert data for rest of the form..

    All of the forums i have visited have been of no use..so have a look at it.the coding is given below:

    Quote:
    Originally Posted by
    This is one of the parts of thee form and not the complete form


    PHP Code:
    <?
     
    include "dbconnect.php";
    //error_reporting('notice');
    if(isset($_POST['submit']))
    {
    //handle the form
         
    $message=NULL
            
             
    $type=$_POST['type'];
     
    $query ="insert into form 
             (type,other,purpose)VALUES('$type','$other','$purp  ose');
     
    $result =mysql_query($query);
             
            if(!$result){die(mysql_error());}
            else {echo 'Record Inserted';}
     
     
     
    <form action="
    <?php echo $_SERVER['PHP_SELF'];?>" method="post" ><table width="90%" align=center cellpadding=2 class=medium>
        <tbody>
          <tr>
            <td width="42%"><font color="#333333" size="1" 
                           face="Verdana, Arial, Helvetica, sans-serif"><br>
             <input type=checkbox name=type[] value=Logo/Brochure> 
                
            Logo/Brochure </font></td>
            <td><font color="#333333" size="1" 
                            face="Verdana, Arial, Helvetica, sans-serif"><br>
                <input type=checkbox value= Software/Web application development  name=type[]>        
            Software/Web Application Development</font></td>
          </tr>
          <tr>
            <td width="42%"><font color="#333333" size="1" 
                            face="Verdana, Arial, Helvetica, sans-serif"><br>
                  <input type=checkbox value=CD presentations  name=type[]>
            CD presentations</font></td>
            <td><font color="#333333" size="1" 
                            face="Verdana, Arial, Helvetica, sans-serif"><br>
                  <input type=checkbox value=2D/3D animations name=type[]>
            2D/3D animations</font></td>
          </tr>
          <tr>
            <td><font color="#333333" size="1" 
                            face="Verdana, Arial, Helvetica, sans-serif"><br>
         
            <input type=checkbox value= Web banner/intro name=type[]> 
               Web Banner/Intro</font></td>
            <td><font color="#333333" size="1" 
                            face="Verdana, Arial, Helvetica, sans-serif"><br>
                  <input type=checkbox value=E-learning  name=type[]>
            E-learning </font></td>
          </tr>
          <tr>
            <td><p><font color="#333333" size="1" 
                            face="Verdana, Arial, Helvetica, sans-serif"><br>
              If other, please explain: </font></p></td>
            <td valign=bottom><div align=right><font color="#333333" size="1" 
                            face="Verdana, Arial, Helvetica, sans-serif">
                <input name="other" type="text" size="50" value="<?php if(isset($_POST['other'])) echo($_POST['other'])?>" >
            </font></div></td>
          </tr>
        </tbody>
      </table></form>
    So this is the code for checkbox...if any have the solution..plz post it

  • #3
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts
    the word array appears because name is an array ,
    you can't store like $name

    store like name[1] , name[2]

    use loop instead

  • #4
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi!!!

    Yes you are right and I also feel the same.But can you elaborate as how to use loop to store $name..in this form case,not in general.

    Regards
    TechnoAtif
    Last edited by TechnoAtif; 01-10-2008 at 08:49 AM.


  •  

    Posting Permissions

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