how to generate a title automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anuragpj
    New Member
    • Jan 2007
    • 32

    how to generate a title automatically

    i have created a drop down list that has the code no. of a subject. now i want that after a user select a code no the title corresponding to that code no. will automatically displayed in the title field.
    How can i do this ?
  • xwero
    New Member
    • Feb 2007
    • 99

    #2
    Originally posted by anuragpj
    i have created a drop down list that has the code no. of a subject. now i want that after a user select a code no the title corresponding to that code no. will automatically displayed in the title field.
    How can i do this ?
    i think you nean something like this

    [PHP]
    <form action="<?php echo $PHP_SELF; ?>" >
    <select name="test">
    <option value="1">test 1</option>
    <option value="2">test 2</option>
    <option value="3">test 3</option>
    <option value="4">test 4</option>
    </select><br>
    <input type="submit" name="send" value="send">
    </form>
    <?php
    if($_POST['send']){
    echo $_POST['test'];
    }
    ?>
    [/PHP]

    This will display the values of the dropdown.

    Comment

    • anuragpj
      New Member
      • Jan 2007
      • 32

      #3
      Originally posted by xwero
      i think you nean something like this

      [PHP]
      <form action="<?php echo $PHP_SELF; ?>" >
      <select name="test">
      <option value="1">test 1</option>
      <option value="2">test 2</option>
      <option value="3">test 3</option>
      <option value="4">test 4</option>
      </select><br>
      <input type="submit" name="send" value="send">
      </form>
      <?php
      if($_POST['send']){
      echo $_POST['test'];
      }
      ?>
      [/PHP]

      This will display the values of the dropdown.
      I dont mean that. I had created a table in database which has code no. and title of that code no. Now I had called the code no. in a drop down list. I want that when a user select a code no the title correspoding to that code displays in the title field. how can i do this?

      Comment

      • xwero
        New Member
        • Feb 2007
        • 99

        #4
        Originally posted by anuragpj
        I dont mean that. I had created a table in database which has code no. and title of that code no. Now I had called the code no. in a drop down list. I want that when a user select a code no the title correspoding to that code displays in the title field. how can i do this?
        In the titlefield of the page?

        Comment

        • devsusen
          New Member
          • Feb 2007
          • 136

          #5
          Hi,

          I think you need to use javascript for this. I am putting a simple example for this bellow.

          Code:
          <html><head><title>title test</title>
          <script language="javascript">
          function fan()
          {
          var k = document.forms[0].aa[document.forms[0].aa.selectedIndex].value;
          document.title = k;
          }
          </script>
          </head>
          <body>
          <form>
          <select name="aa" onChange="fan()">
          <option value="1111">1111</option>
          <option value="2222">2222</option>
          <option value="3333">3333</option>
          </select></form>
          </body>
          </html>

          Comment

          Working...