my page work like this:

you get info about an person on one page, then you click on a radiobutton to get another persons info on the page.

I have a pulldownmeny where users can choose to only see info about persons who have answered YES or NO on a question. Say that I choose only to view persons who have answered YES on the question, it works this far, BUT when i click the radiobutton to get the next persons info this YES value isn't there anymore. How do I make this??

I use this code on the pulldownmeny:

<form action="index.php" method="post"> 
<select name="kon" onchange="this.form.submit()"> 
<option value="">Välj</option> 
<option value="YES" <?php echo ($_POST["kon"] == "Y" ? "SELECTED" : ""); ?>>YES</option> 
<option value="M" <?php echo ($_POST["kon"] == "N" ? "SELECTED" : ""); ?>>NO</option> 
<option value="">Show both</option> 
</select> 
</form> 

    Hi,

    perhaps a silly question, but eh.. You do submit "kon"again when people click on the radio button, don't you? If you'dont, it is of course not going to work.

    J.

      No the radiobutton dont submit "kon", it submit a rating value = if you liked or not liked the persons oppinions.

      That is the problem. I have 2 forms (actually gonna be 3) one that sets the "kon" value and one that sets the "r" value.

      r value is radiobutton
      kon i pulldown menu

      the pulldownmenu sorks like it should, submits the value and the page reloads with another users info on the page and the radiobuttons all empty.

      But the kon menu is a problem. If a visitor to the page chose YES in the pulldownmenu then it randomly shows info about a YES-user CORRECT this far. But now when the visitor clok one of the radiobuttons the page reloads as it should but the value in the pulldown is now not chosen to YES (or what the visitor chosed from the begnning)

        Well,

        If you don't resubmit the "kon" value, then You'll have to store it in a different way. Either throgh a session variable, or you could add it to the action of your second form:

        $kon = $_POST["kon"] ;
        <form name=\"form2\" action=\"somepage.php?kon=$kon\">
        

        Or you could consider combining all forms into one form.

        J.

          should i put it in the kon or r form??

            Hi,

            you should put it in the 'r' form as you put it.

            but eeh.. Why not combine all in one form?

            J.

              actually I havent thinked about it.

              I thought it was easier to make seperate, there are going to be one more radiobutton selection that also have to be permanent as the kon value

                mmhhh dont get it to work. it just do the same thing as earlier but now with the selected r value in the adressbar in IE.

                should it look like this?

                <?
                $kon = $_POST["kon"] ;
                ?>
                <form name=_rateForm action=\index.php?kon=$kon\>              
                <input type=radio name=r value=1 onclick="this.form.submit()"> <input type=radio name=r value=2 onclick="this.form.submit()">

                  Try:

                  <?
                  $kon = $_POST["kon"] ;
                  ?>
                  <form name=_rateForm action=index.php?kon=<? echo $kon; ?>>              
                  <input type=radio name=r value=1 onclick="this.form.submit()"> <input type=radio name=r value=2 onclick="this.form.submit()">

                    Hi,

                    Hmmm.. it probably has to do with that variable not being present in the $_post[] array. (what is the HTML source code you get for the form?

                    :

                    <form name=_rateForm action=index.php?kon=>              
                    <input type=radio name=r value=1 onclick="this.form.submit()"> <input type=radio name=r value=2 onclick="this.form.submit()">

                    ?

                    How about adding $kon as a hidden variable in your form instead:
                    <input type="hidden" name ="kon" value="<?echo $kon ?>">

                      sorry but which of the forms you mena now?? still the r form?

                        tried to add that code in the r form, still no difference altough it now prints: index.php?kon=Y in the url bar... (N if i choose NO in the drop menu)

                          Hi, Not tested, but I think this should olve your headache?

                          J.

                          <?
                          
                          if (isset($_post['kon']) and $POST['kon'] != "")
                            {
                            $konecho = "<input type=\"hidden\" name =\"kon\" value=\"$kon\">"
                            }
                          ?>
                          
                          
                          <form action="index.php" name="allform" method="post"> 
                          
                          <select name="kon" onchange="this.form.submit()"> 
                          <option value="">Välj</option> 
                          <option value="YES" <?php echo ($_POST["kon"] == "Y" ? "SELECTED" : ""); ?>>YES</option> 
                          <option value="M" <?php echo ($_POST["kon"] == "N" ? "SELECTED" : ""); ?>>NO</option> 
                          <option value="">Show both</option> 
                          </select> 
                          
                          
                          <input type=radio name=r value=1 onclick="this.form.submit()"> 
                          <input type=radio name=r value=2 onclick="this.form.submit()"> 
                          
                          <? echo $konecho ?>
                          
                          </form> 
                          
                          

                            im currently testing this. Get parsing error but probably just me that scew things up.

                            I let u know when finished

                              hi,

                              Yeah, I found one ; is missing:

                              $konecho = "<input type=\"hidden\" name =\"kon\" value=\"$kon\">"

                              should be

                              $konecho = "<input type=\"hidden\" name =\"kon\" value=\"$kon\">";

                              and

                              <? echo $konecho ?>

                              should be

                              <? echo $konecho; ?>

                                Yes !!

                                Big big thanks for your effort! it works now!

                                anyway, now there is the next challenge. I want to have radiobuttons that are done in the sameway as we did with the pulldown meny. theese radiobuttons are North South Middle Eastern and West

                                <form name="form1" method="post" action="">
                                              <input type="radio" name="kateg" value="N" onclick="this.form.submit()">North<br>
                                			<input type="radio" name="kateg" value="S "onclick="this.form.submit()">South<br>
                                			<input type="radio" name="kateg" value="M" onclick="this.form.submit()">Middle <br>
                                			<input type="radio" name="kateg" value="W" onclick="this.form.submit()">West<br>
                                			<input type="radio" name="kateg" value="E" onclick="this.form.submit()">East </form>

                                Can we do something like we did with the R form ?

                                EDIT took away the parse error comment as u posted the real answer

                                  Hi,

                                  Good to hear that this works. Save it somewhere, and play around with it to solve the rest of the forms. If you are really stuck again.. Put up a new thread.

                                  Good luck.

                                  J.
                                  (I am off to solve my owm problems..)

                                    sounds good.

                                    Thanks once again, that was beyond my knowledge.

                                      Write a Reply...