<td width="186" align="right"><label for="collegetxt"></label>
  <select name="collegecategory"  dir="rtl" id="collegecategory" class="title">
                <option value="-1">Choose college</option>
              <?php

                $rs=$db->GetAllCollegCategory();
                while(list($name)=mysql_fetch_array($rs)){
                    echo "<option ".($collegSearch==$name?" selected=selected ":"")." value='$name'>$name</option>";
             } ?>

        </select>
        </td>

      </tr>
      <tr>
      <td> <strong>Teacher Number:</strong></td>
      <td width="217" align="right"><label for="Teachesearch"></label>
        <label for="TeacherNo"></label>
        <input type="text" name="TeacherNo" id="TeacherNo" class="title" checked="checked"/></td>
        <input type="submit" name="evlBtn1" id="evlBtn1" value="Evaluate" style="width:119px;height:39px;font-size:16px;" />

Hi,
i don't know how to keep the <input type="text"/> selected whenever i've pressed the Evaluate button
as the <select> value above was seleced ?!!

how can i keep it checked or selected..?!!

Would it be possible to see all your code for this? I'm a bit rusty on my PHP but want to try to help.

Member Avatar for Zagga

Hi,

At the top of the page, create a blank variable $teacherNo. Check if the form field has been filled in, if it has set it as the $teacherNo variable.

<?php
$teacherNo = "";
if (isset($_POST['TeacherNo'])){
<?php
$teacherNo = "";
if (isset($_POST['TeacherNo'])){
    $teacherNo = $_POST['TeacherNo'];
}
?>

Then in your form, echo the variable

<input type="text" name="TeacherNo" id="TeacherNo" class="title" checked="checked"/><?php echo $teacherNo; ?></td>

(Or is that supposed to be a checkbox input, not text?)

<?php
$che = "";
if (isset($_POST['TeacherNo'])){
    $che = "checked='checked'";
}
?>
<input type="checkbox" name="TeacherNo" id="TeacherNo" class="title" $che/></td>

I attached snap shot, what i did mean in my question is how i can save the field value slected after clicking on the Evaluate button!

as you can see the year field and college field value has stilled selceted, how can i did this to the teacher number field??!!

oh! i figure it out

thank you all :D

  <input type="text" name="TeacherNo" id="TeacherNo" class="title" value="<?php echo $techerS; ?>" checked="checked"/></td>

i've put the echo at the value""

Member Avatar for Zagga

Glad you figured it out.
As a side note, checked="checked" in a text input box does nothing. It is only used in checkbox inputs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.