Display php forms on click of radiobuttons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TechnoAtif
    New Member
    • Sep 2007
    • 63

    Display php forms on click of radiobuttons

    Hi all. I have stuck up with a new problem.Hope anyone can find some solution for that.
    I have three radiobuttons and the situation is that on click of each radio button a new php page is to be opened. I have done it using submit button. But actually it has to be done ON CLICK of the radiobuttons on not on SUBMIT.

    The code i used for submit is given below. PLz help to customize this code so as to be helpful to satisfy the demanded situation

    Thanks and Regards
    TechnoAtif

    [PHP]<form name="myForm" action="log_in. php" method="get">
    <input type="radio" name="r" value="archilog in.php" selected="selec ted" onclick="this.f orm.action=this .value;"> Architects<br>
    <input type="radio" name="r" value="conslogi n.php" onclick="this.f orm.action=this .value;"> Consultants<br>
    <input type="radio" name="r" value="varlogin .php" onclick="this.f orm.action=this .value;"> Others<br>
    <input type="submit" value="Submit">
    </form>[/PHP]
  • TechnoAtif
    New Member
    • Sep 2007
    • 63

    #2
    In addition to the code mentioned in my first post i have also made use of headers as the alternatite solution.But it also works on click of SUBMIT buttton and not just clicking the radiobutton. THe code is given below.Anyone kindly rescue me.

    Thanks and Regards
    TechnoAtif

    [PHP]

    <?php

    $host=$_SERVER['HTTP_HOST'];
    $folder="archid esign";



    if (isset($_POST['submit'])) {

    $selected_radio = $_POST['login_page'];

    if ($selected_radi o == 'archi') {
    header("Locatio n:http://$host/$folder/archilogin.php" );
    }
    else if ($selected_radi o == 'consult') {
    header("Locatio n:http://$host/$folder/conslogin.php") ;
    }

    else if ($selected_radi o == 'various') {
    header("Locatio n:http://$host/$folder/varlogin.php");
    }

    }

    ?>[/PHP]

    [HTML]<form name="form1" method="post" action="log.php ">
    <table width="194">
    <tr><td><h1 class="articles ">Members Login</h1></td>
    </tr>
    <tr>
    <td width="114">

    <input type="radio" name="login_pag e" value="archi">
    Architects</td></tr>

    <tr><td width="114">
    <input type="radio" name="login_pag e" value="consult" >
    consultants</td></tr>

    <tr><td width="114">
    <input type="radio" name="login_pag e" value="various" >
    Others</td><td width="68"><inp ut name="submit" type="submit" value=go></td>
    </tr></table>
    </form>[/HTML]

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Use location.href to go to a new page, as follows:
      [html]
      <input type="radio" name="r" value="archilog in.php" selected="selec ted" onclick="locati on.href=this.va lue;"> Architects<br>
      <input type="radio" name="r" value="conslogi n.php" onclick="locati on.href=this.va lue;"> Consultants<br>
      <input type="radio" name="r" value="varlogin .php" onclick="locati on.href=this.va lue;"> Others<br> [/html]
      Ronald

      Comment

      • TechnoAtif
        New Member
        • Sep 2007
        • 63

        #4
        Hey !!! Thanx Roverdonk.

        You made my day. it was so simple.I will be back here on this forum to have some xtra tips if some othre problem exist s.Until then...bye.and great job [:)]

        Thanx and Regards
        TechnoAtif

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          You are welcome. See you next time.

          Ronald

          Comment

          Working...