Two options in select list menu

Let's say I have a select (list/menu) and I've added a dynamic source to it.
The menu will show a list of names.  However, in the database the names are stored in two tables:
first_name
last_name
I don't want the list to just show last names because what if more than one person has a last name, how would you know who is who?
So, I've tried to get it to show the first and last name.   Here is the code with just a last name showing:
<label for="employees"></label>
            <select name="employees" id="employees">
              <?php
do { 
?>
              <option value="<?php echo $row_getEmployee['employee_id']?>"><?php echo $row_getEmployee['lastname']?></option>
              <?php
} while ($row_getEmployee = mysql_fetch_assoc($getEmployee));
  $rows = mysql_num_rows($getEmployee);
  if($rows > 0) {
      mysql_data_seek($getEmployee, 0);
            $row_getEmployee = mysql_fetch_assoc($getEmployee);
?>
          </select>
The important part being:
I tried changing this:
<option value="<?php echo $row_getEmployee['employee_id']?>"><?php echo $row_getEmployee['lastname']?></option>
to this:
<option value="<?php echo $row_getEmployee['employee_id']?>"><?php echo $row_getEmployee['firstname' . 'lastname']?></option>
but that only showed the first letter of each last name and nothing else. 
So - does anyone know how I could do this?

Ok, first my standard disclaimer - I do not know PHP. But it seems to me that you can't include both column names in one call to the recordset. Try this instead:
<option value="<?php echo $row_getEmployee['employee_id']?>"><?php echo $row_getEmployee['firstname']." ".$row_getEmployee['lastname']?></option>
However, I would probably do my concantenation in the SQL select instead.

Similar Messages

  • Select list/menu to automatically show the numbers 0-99?

    Hi
    I have a select list/menu on my page and I would like the list to automatically show the numbers 0-99.
    Been searching the interwebs for answers/tutorials, but no luck.
    Any clues?
    Using CS5, asp
    Regards,
    Christian

    Thanks for everyone advise. I managed to get it working
    I sent the stockID on;y to the cart page, made a new variable based on the stockID the made a query and got all the information based on the new stockID variable
    <?php
    $newStockID = $XCart_StockID = ${$XCName}["contents"][0][$XCart__i];
    mysql_select_db($database_beau, $beau);
    $query_rsSize = "SELECT * FROM beauAW13_SizeList, beauAW13_Stock WHERE beauAW13_Stock.SizeID = beauAW13_SizeList.SizeID AND beauAW13_Stock.StockID = '$newStockID'";
    $rsSize = mysql_query($query_rsSize, $beau) or die(mysql_error());
    $row_rsSize = mysql_fetch_assoc($rsSize);
    $totalRows_rsSize = mysql_num_rows($rsSize);
                              ?>
    select list
    <option value="<?php echo $row_rsProduct['StockID']; ?>"><?php echo $row_rsProduct['Size']?></option>

  • If i have two option to select between XI or BW which one in better and why

    if i have two option to select between XI or BW which one in better and why
    both in terms of money and in terms of my career growth.......

    Sheetika,
    XI if you  are good in JAVA.The rest is same for both XI and BW.
    K.Kiran.

  • Select option in select list and navigate to different page

    Hello,
    I have a tabular form.One of the item is a select list with 2 options. Selecting option one should take the user to page10(just an example) and display all the values of that particular row. Similarly selecting option 2 should take the user to page 20 and display all the values of that row.
    Can some one guide me how to do above mentioned job.
    Thanks in advance.
    Pravish

    @Avinash
      if f_cat-seltext_m = 'Select'.
        f_cat-col_pos = 1.
        f_cat-seltext_l = 'EDIT'.
        f_cat-Checkbox = 'X'.
        f_cat-EDIT = 'X'.
      endif.
    I am already passing f_cat-checkbox = 'X'.
    Thanks
    Kumar.

  • Insert items from two different Multiple Select Lists into a single table

    I need help. I have a training tracking system that tracks the courses taken by employees.
    I have created two multiple select lists, one is SelectEmployees and the other is SelectCourses. I want to insert
    the selected item from those two multiple select lists into Training_Record table.
    Note, SelectEmployees" is from Employee table and SelectCourses is from Courses table. Those two table has no intersetion.
    Train_Record is the table that joins those two together.
    Please advice and your help is appreciate.

    Thank you for your help.
    I tried your code and changed the table/field name to my actual table/field name and the iitem name to actual item name.
    declare
    cursor c_Employees is
    select PERSONNEL_NEW.EMPLOYEEID from PERSONNEL_NEW where PERSONNEL_NEW.EMPLOYEEID in (:P15_SELECTEDEMP);
    cursor c_Courses is
    select COURSES.COURSE_ID from COURSES where COURSES.COURSE_ID in
    (:P15_SELECTEDCOUR);
    begin
    foreach :=r_employee in c_Employees loop
    foreach :=r_course in c_Courses loop
    insert
    into COPYOFTRAINREC ( EMPLOYEEID, COURSEID )
    values ( r_employee.EMPLOYEEID, r_course.COURSE_ID );
    end loop;
    end loop;
    end;
    I got error message as :
    ORA-06550: line 12, column 25: PLS-00103: Encountered the symbol "C_EMPLOYEES" when expecting one of the following: (
    Error
    OK

  • Stoping "Plesae Select" List/Menu Results from coming through

    Hi there, we have several list/menu's on our website form and
    want to know if theres a way of stopping all the "please select"
    results from coming through?
    "please select" comes through because the user hasent
    selected a result in the list menu.
    Cheers
    Malhyp

    MalRom wrote:
    > Hi there, we have several list/menu's on our website
    form and want to know if
    > theres a way of stopping all the "please select" results
    from coming through?
    >
    > "please select" comes through because the user hasent
    selected a result in the
    > list menu.
    As well as what Gary has suggested, you should always
    validate the input
    being submitted via a form. This can be done client-side with
    Javascript, or server-side with whatever language is
    available. It
    sounds like you can't edit the CGI which processes the form
    data and
    sends it, so do as Gary suggested, or use some client-side
    form
    validation. There are loads of examples online if you google
    for
    "javascript form validation"
    Dooza
    Posting Guidelines
    http://www.adobe.com/support/forums/guidelines.html
    How To Ask Smart Questions
    http://www.catb.org/esr/faqs/smart-questions.html

  • List/Menu (multiple selected)  insert into MySQL

    I have been building a feedback form and I am running into a
    issue that when I place a list/menu that allows multiple selections
    when I submit my form in my MySQL database it collected the
    information but only on the last multiple selection.
    For example, this is what my list/menu looks like.
    <select name="occasion" size="5" multiple="MULTIPLE"
    id="occasion">
    <option value="Spur of the moment,">Spur of the
    moment</option>
    <option value="Family dinner">Family
    dinner</option>
    <option value="Special occasion (i.e.
    birthday)">Special occasion (i.e. birthday)</option>
    <option value="Office get together">Office get
    together</option>
    <option value="Romantic dinner">Romantic
    dinner</option>
    <option value="Night out with friends">Night out with
    friends</option>
    <option value="Business meeting">Business
    meeting</option>
    <option value="Other">Other</option>
    </select>
    And my MySQL database I have it set up as...
    Field Type
    occasion mediumtext
    I do not know why I cannot have more than one selection
    inputed into my field, what must I do to correct this? Everything
    works perfectly expect the multi selected list/menu. I want to
    place all that is selected in the list/menu in that one database
    field called occasion.

    .oO(MikeL7)
    >>You should also test with isset() and is_array() if
    $_POST['occasion']
    >>is available at all and of the expected type. The
    code above will also
    >>throw a notice if $insert_string is not initialized
    before the loop.
    >
    > I use both isset and is_array in my code, When you say
    notice, you dont mean
    >a script stoppiong error?
    Nope. An E_NOTICE error won't terminate the script, but
    shouldn't happen
    nevertheless. While developing, the error_reporting directive
    should be
    set to E_ALL|E_STRICT and _all_ reported problems should be
    solved. It's
    not only better coding style, but also helps to prevent real
    errors. In
    this particular case it was just a guess, because it was only
    a part of
    the code. But using an uninitialized variable with a '.='
    operator for
    example would lead to a notice, which should be fixed.
    >>But of course this is a really bad DB design, as it
    already violates the
    >> first normal form (1NF). Just some ideas for queries
    that might come to
    >> mind, but would be really hard to do with such a
    comma-separated list:
    >
    > A better table design would be to have column for |
    list_ID | user_ID |
    >song_ID | and do a insert for each song selected.
    Yes, something like that.
    >Thanks for the input, i like escaping the variables from
    a string as they
    >stand out more in code view, is the single quote method
    faster? And which one
    >will be or is already deprecated?
    All are correct and won't be deprecated. IMHO it's more or
    less just
    personal preference. It also depends on the used editor and
    its syntax
    highlighting capabilities. For example I use Eclipse/PDT for
    all my PHP
    scripts, which can also highlight variables inside a string.
    But if the
    above is your preferred way, there's nothing really wrong
    with it.
    Just some additional thoughts:
    Personally I prefer as less escaping and concatenating as
    possible,
    because such a mixture of single quotes, double quotes, dots
    and
    sometimes even escaped quote signs (for example when printing
    HTML)
    _really_ confuses me. I like to keep my code clean and
    readable.
    Something like this:
    print "<img src=\"".$someVar."\" ...>\n";
    not only hurts my eye, it is also quite error-prone. It's
    easy to miss a
    quote or a backslash and get a parse error back, especially
    in editors
    with limited syntax highlighting (or none at all). So I would
    prefer
    print "<img src='$someVar' ...>\n";
    or even
    printf("<img src='%s' ...>\n", $someVar);
    When it comes to performance issues, of course there's a
    difference
    between the various methods. But for me they don't really
    matter. In
    practice you usually won't notice any difference between an
    echo, a
    print or a printf() call for example, as long as you don't
    call them
    a million times in a loop.
    So I always just use the method that leads to the most
    readable code.
    In many cases, especially when a lot of variables or
    expressions are
    involved, (s)printf() wins. Not for performance, but for
    readability.
    But as said - personal preference. YMMV.
    Micha

  • I have a mac pro wich will not open windows in boot camp i get to the two options select windows but iyt will not load can you help please

    i have a mack pro which will not open in windows from boot camp get to the two options and select windows drive but it will not open can you help Please

    Hi there, Well, i thing i might have had the same problem (if you dont mean the selecting part, then try keyboad with usb and without if u dont have a macbook pro or so), i did the same and after selecting windows it said "No bootable disk" or " no boot disk" or something like that and the installer wont start when i was trying to install via CD/DVD.
    The sulution is to use 2 usb-drives, one for the support drivers from apple and one for the windows it self after burning the CD/DVD to the usb on a PC using the windows own tools and creating a ISO file.
    (there might be problems whit CD/DVD install sometimes)
    The ISO file on a own USB is the most importat thing!! (and even apple and windows didnt know that but me and a technikal support guy from the store i bought it managed to fix it after like 4 days )
    Hope it work now mate!

  • Select list in radiogroup options

    Is there any way to achieve the following layout
    o Radiogroup Option 1 [Select List] o Radiogroup Option 2Yes, I can easily do
    o Radiogroup Option 1 [Select List]
    o Radiogroup Option 2which is close enough, but just wondering if the other one was possible.
    Thanks

    The best I could come up with was to use the second layout I mention and then add some Javascript on the page to do something like
    <style type="text/css">
    label.l {position:absolute;top:100px;left:210px;}
    input.i {position:absolute;top:100px;left:200px;}
    </style>
    <script type="text/javascript">
    var f=$x('P1_RADIO');
    var l=f.getElementsByTagName('label')[1];
    var i=f.getElementsByTagName('input')[1];
    l.className += "l";
    i.className += "i";
    </script>Basically, it takes that "Radiogroup Option 2" and the form input field and uses absolute CSS positioning to place it to the right of the Select list.
    Works great in FF (as usual), but the usual IE inconsistencies with CSS box model rear their ugly head. Looks terrible in IE, totally mis-aligned.
    Any other ideas?
    Thanks

  • How to change a list/menu to a text field when 'Other' is chosen?

    Hi there. I've been trying to solve this for a week now and I have depleted all my resources, that is why I'm here. I even went to jquery but nothing works and I think I was over-complicating this way too much.
    In short: I have a contact form, which have a list/menu with validation, and one of the options of that list/menu is "other". What I want is that when the user select "other" automatically change to a text field in order to let the user put his custom color. This is what I have:
    <form method="post" action="process.php">
    <span id="spryselect1">
    <label for="colors"></label>
    <select name="colors" id="colors">
    <option selected="option1">Blue.</option>
    <option value="option2">White</option>
    <option value="option3">Red</option>
    <option value="other">other</option>
    </select>
    <span class="selectRequiredMsg">Please select a colour.</span></span>
    <input type="submit" value="Send">
    </form>
    I know now that the approach is to show/hide a separate textbox besides the other... well. I don't know how to implement that, I think I really need your help guys. I'm completely frustrated.
    Thanks in advance.

    Have a look at the following
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    <link href="http://labs.adobe.com/technologies/spry/widgets/selectvalidation/SpryValidationSelect.css" rel="stylesheet">
    <link href="http://labs.adobe.com/technologies/spry/widgets/textfieldvalidation/SpryValidationTextField.css" rel="stylesheet">
    <style>
    .hidden {display:none;}
    </style>
    </head>
    <body>
    <form action="" method="post">
      <span id="spryselect1">
      <label for="colors">Colours:</label>
      <select name="colors" id="colors" onchange="MyOnClickHandler(this.value)">
        <option value="">Please select...</option>
        <option value="blue">Blue</option>
        <option value="white">White</option>
        <option value="red">Red</option>
        <option value="other">other</option>
      </select>
      <span class="selectRequiredMsg">Please select a colour.</span></span><span id="sprytextfield1">
      <input name="other" id="other" class="hidden" type="text">
      <span class="textfieldRequiredMsg">A value is required.</span></span>
      <input name="" type="submit">
    </form>
    <script src="http://labs.adobe.com/technologies/spry/includes_minified/SpryDOMUtils.js"></script>
    <script src="http://labs.adobe.com/technologies/spry/includes_minified/SpryValidationSelect.js"></script>
    <script src="http://labs.adobe.com/technologies/spry/includes_minified/SpryValidationTextField.js"></script>
    <script>
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
    var sprytextfield1;
    function MyOnClickHandler(value) {
         if(value =='other') { //show text field and set validation
              if(!sprytextfield1){
              sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
              Spry.$$('input#other').removeClassName('hidden');
         } else { //hide textfield and destroy validation
              if(sprytextfield1 && sprytextfield1.destroy){
                   sprytextfield1.resetClasses();
                   sprytextfield1.destroy();
                   sprytextfield1 = null;
              Spry.$$('input#other').addClassName('hidden');
         return false;
    </script>
    </body>
    </html>
    Gramps

  • Please help! How can I validate Radio Buttons and List Menu with PHP.

    Hello everyone, I have been learning PHP step by step and
    making little projects.
    The point is I find it easy to learn by doing "practical
    projects."
    I have been reading the David Powers's Book on PHP Solutions
    and it's really great, however there is nothing mentioned regarding
    Validating Radio buttons. I know the book cannot cover every aspect
    of PHP and maybe someone in here can help.
    I have been learning how to process HTML forms with PHP.
    The problem is every book or tutorial I have read or
    encountered fall short on validation.
    I'm wondering how I can learn to validate Radio Buttons and
    Select List Menu.
    I have managed to create validation for all other fields but
    have no clue as to how I can get validation for Radio Buttons and
    List Menu.
    I would also like an error message echoed when the user does
    not click a button or make a selection and try to submit the form.
    I would appreciate any help.
    Patrick

    It's not that default value is "None." In fact it's not. It
    will only be
    "none" when the form is submitted.
    Also if your submit button is names 'send' then
    $_POST['send'] will only be
    set if the form was submitted.
    Make sure you didn't hit the refresh button on your browser
    which usually
    reposts the information. Also make sure you did not reach the
    form from
    another form with the same button names.
    Otherwise paste the snippet.
    Also you can check what fields are set in the post array by
    adding this to
    the top of (or anywhere on) your page:
    print_r($_POST);
    Cosmo
    "Webethics" <[email protected]> wrote in
    message
    news:[email protected]...
    >
    quote:
    Originally posted by:
    Newsgroup User
    > Off the top of my head this should be no different than
    your radio buttons
    > except that 'productSelection' will always fail the
    !isset check when the
    > form is submitted since the default value is "None", and
    therefore always
    > set. :-)
    >
    > So how about this..?
    > <?php
    > if (isset($_POST['send']) and
    ($_POST['productSelection'] == "None"))
    > {echo "Please select a product.";}
    > ?>
    >
    >
    >
    >
    > "Webethics" <[email protected]> wrote
    in message
    > news:[email protected]...
    > > Another question - how do i applied the code you
    just showed me to
    > > select
    > > menu
    > > or select list?
    > >
    > > This is the list:
    > >
    > > <div class="problemProduct">
    > > <label for="productSelection"><span
    class="product_label">Product
    > > Name.</span></label>
    > > <select name="productSelection" id="products"
    class="selection">
    > > <option value="None">-------------Select a
    product----------</option>
    > > <option value="Everex DVD Burner">Everex DVD
    Burner</option>
    > > <option value="Vidia DVD Burner">Vidia DVD
    Burner</option>
    > > <option value="Excerion Super Drive">Excerion
    Super Drive</option>
    > > <option value="Maxille Optical Multi
    Burner">Maxille Optical Multi
    > > Burner</option>
    > > <option value="Pavilion HD Drives">Pavilion
    HD Drives</option>
    > > </select>
    > > </div>
    > >
    > > I thought I could just change the name is the code
    from operatingSystem
    > > to
    > > productSelection.
    > >
    > > Something like this:
    > >
    > > From this:
    > >
    > > <?php
    > > if (isset($_POST[send]) and
    !isset($_POST['operatingSystem']))
    > > {echo "Please select an operating system.";}
    > > ?>
    > >
    > > To this:
    > >
    > > <?php
    > > if (isset($_POST[send]) and
    !isset($_POST['productSelection']))
    > > {echo "Please select an operating system.";}
    > > ?>
    > >
    > > But this does not work, any ideas?
    > >
    > > Patrick
    > >
    >
    >
    >
    >
    > Hey, I tried this about but as you mentioned, since the
    default product
    > value
    > is "None" an error message appears when the page loads.
    >
    > Is there a way to code this things so that even though
    the default value
    > is
    > "None" there ia no error message untle you hit the
    submit?
    >
    > When I applied the code, it messes up the previous code,
    now the operating
    > system is requiring an entry on page load.
    >
    > When I remove the code from the list menu everything
    goes back to normal.
    >
    > I know this is a little much but I have no other
    alternatives.
    >
    > Patrick
    >

  • Dynamically change the value of a select list in form based on a table

    Hi Friends,
    I am using a form based on a table. I want to display two fields as select lists instead of text boxes and when a value
    in a select list is selected, the corresponding values will be listed in the next select list. For example if department
    value is selected in a select list the employees in that department will be listed in the employee select list. I saw a
    metthod using ajax for achieving this in tabular form in Denes's sample application[Click Here| http://apex.oracle.com/pls/otn/f?p=31517:176:462842537250908::NO] .
    Is there any way to achieve the same for a form based on a table,
    Thanks,
    Tj

    Hi Andy,
    Could you tell me how I could use your example with multiple Application Items?
    My page has 3 cascading select lists. The second is dependent on the first and the third is dependent on both the first and second. I thought I would just need to add the second application item as a get, but not sure what the syntax would be. I have troubleshooted to the point where my select list refreshes when I have one in the javascript...just not sure how to add the additional one?
    Here's what I have (I have been referencing your 'Get Employees' page)
    My Page Items:
    P0_VENDOR_ID
    P0_VENDOR_SITE_ID
    P0_INVENTORY_ITEM_ID
    My Application Items:
    F_VDR_ID
    F_VDR_SITE_ID
    My query in the application process has both F_VDR_SITE_ID and F_VDR_ID in it.
    My javascript function...this worked OK until I added the additional get.add('F_VDR_SITE_ID')
    function getItems(filter, listName)
    var xml = null;
    var list = document.getElementById(listName);
    var listvalue = list.value;
    var get = new htmldb_Get(null,$v('pFlowId'), 'APPLICATION_PROCESS=Set_Items',4);
    get.add('F_VDR_ID', filter.value);
    get.add('F_VDR_SITE_ID', filter.value);
    ret = get.get('XML');
    if(ret)
    var s = ret.getElementsByTagName("select");
    if(s){
    var o = ret.getElementsByTagName("option");
    var oCount = o.length;
    list.options.length = 0;
    for(var i = 0; i < oCount; i++){
    var l_Opt_Xml = o;
    appendToSelect(list, l_Opt_Xml.getAttribute('value'), l_Opt_Xml.firstChild.nodeValue);
    list.value = listvalue;
    if (list.selectedIndex == -1)
    list.selectedIndex = 0;
    get = null;
    Thanks,
    Janel

  • Conditional Validation on Textfield(s) based on Select/List - help needed.

    Hey Gang,
    I have a simple page where a select/list menu with values "1" through "5" determines how many following textfields require validation. There is an "onchange" event which calls a function to update the validation. Below is my code:
    [ body tag *spry js/css scripts are called in head]
    <form id="form1" name="form1" method="post" action="">
      <p>
          <select name="menu" id="menu" onchange="menuFunction()">
            <option value="0" selected="selected">0</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
          </select>
      </p>
      <p>
        <span id="sprytextfield1"><input type="text" name="text1" id="text1" /></span><br />
        <span id="sprytextfield2"><input type="text" name="text2" id="text2" /></span><br />
        <span id="sprytextfield3"><input type="text" name="text3" id="text3" /></span><br />
        <span id="sprytextfield4"><input type="text" name="text4" id="text4" /></span><br />
        <span id="sprytextfield5"><input type="text" name="text5" id="text5" /></span>
      </p>
    <p><input type="submit" name="submit" id="submit" value="Submit" /></p>
    </form>
    <script type="text/javascript">
    <!--
    function menuFunction() {
          var menuNum = document.getElementById('menu').value;
         for(i=1; i<=5; i++) {
               if(i<=menuNum) {
                    eval("var sprytextfield" +i+ "= new Spry.Widget.ValidationTextField(\"sprytextfield" +i+ "\")" );
               } else {
                   eval("var sprytextfield" +i+ "= new Spry.Widget.ValidationTextField(\"sprytextfield" +i+ "\", \"none\", {isRequired:false})" );
    //-->
    </script>
    [ / body tag etc... ]
    The function seems to work when it requires the validation for the textfields, but not when removing the validation. I've tried doing  eval("sprytextfield" +i+ ".destroy()"); as well without success.
    I've searched through forums and could not find an answer to this (sorry if I missed it)  ... so hopefully somebody can point me in the right direction. (*I found the post w/ the link http://www.spry-it.com/examples/spry-widget-validation-generation-and-destroy/ -- however that page doesn't seem to work *Chrome)
    Thanks for any help! =)
    ~Mike

    Have a look here http://forums.adobe.com/message/2651124#2651124
    If that doesn't help please come back here.
    Ben

  • Creating dependent select list menus with javascript

    Hi Everybody,
    I m creating parent and child select list menu. Value of Child menu would be dependent on the value selected in the parent menu. I have tried to implement a code from adobe labs  (http://kb2.adobe.com/cps/149/tn_14924.html) but many strange javascript errors are coming up.
    My code is given below:
    <?php require_once('../Connections/connection.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    mysql_select_db($database_connection, $connection);
    $query_sector = "SELECT * FROM sector WHERE media_code = 100 ORDER BY sector_desc ASC";
    $sector = mysql_query($query_sector, $connection) or die(mysql_error());
    $row_sector = mysql_fetch_assoc($sector);
    $totalRows_sector = mysql_num_rows($sector);
    mysql_select_db($database_connection, $connection);
    $query_rsList2 = "SELECT subsector_code, subsector_desc, sector_code FROM sub_sector ORDER BY sector_code ASC";
    $rsList2 = mysql_query($query_rsList2, $connection) or die(mysql_error());
    $row_rsList2 = mysql_fetch_assoc($rsList2);
    $totalRows_rsList2 = mysql_num_rows($rsList2);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <!-- Dynamic Dependent List box Code for *** JavaScript *** Server Model //-->
    <script >
    <!--
    var arrDynaList = new Array();
    var arrDL1 = new Array();
    arrDL1[1] = "selList1";              
    // Name of parent list box
    arrDL1[2] = "form1";                 
    // Name of form containing parent list box
    arrDL1[3] = "selList2";              
    // Name of child list box
    arrDL1[4] = "form2";                 
    // Name of form containing child list box
    arrDL1[5] = arrDynaList;
    <%
    var txtDynaListRelation, txtDynaListLabel, txtDynaListValue, oDynaListRS; txtDynaListRelation = "sector_code";
    // Name of recordset field relating to parent
    txtDynaListLabel = "subsector_desc";
    // Name of recordset field for child Item Label
    txtDynaListValue = "subsector_code";
    // Name of recordset field for child Value
    oDynaListRS = rsList2;
    // Name of child list box recordset
    var varDynaList = -1;
    var varMaxWidth = "1";
    var varCheckGroup = oDynaListRS.Fields.Item(txtDynaListRelation).Value; 
    var varCheckLength = 0;
    var varMaxLength = 0;
    while (!oDynaListRS.EOF){
    if (varCheckGroup != oDynaListRS.Fields.Item(txtDynaListRelation).Value) {
        varMaxLength = Math.max(varCheckLength, varMaxLength) varCheckLength = 0; }
        %>
        arrDynaList[<%=(varDynaList+1)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListRelation).Value)%>";
        arrDynaList[<%=(varDynaList+2)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListLabel).Value)%>";
        arrDynaList[<%=(varDynaList+3)%>] = "<%=(oDynaListRS.Fields.Item(txtDynaListValue).Value)%>";
        <%
        if (oDynaListRS.Fields.Item(txtDynaListLabel).Value.length > varMaxWidth.length) { 
        varMaxWidth = oDynaListRS.Fields.Item(txtDynaListLabel).Value; }
        varCheckLength = varCheckLength + 1; varDynaList = varDynaList + 3;
        oDynaListRS.MoveNext(); }
        varMaxLength = Math.max(varCheckLength, varMaxLength);
        %>
    //--></script>
    <!-- End of object/array definitions, beginning of generic functions -->
    <script >
    <!--
    function setDynaList(arrDL){
    var oList1 = document.forms[arrDL[2]].elements[arrDL[1]];
    var oList2 = document.forms[arrDL[4]].elements[arrDL[3]];
    var arrList = arrDL[5];
    clearDynaList(oList2);
    if (oList1.selectedIndex == -1){
    oList1.selectedIndex = 0; }
    populateDynaList(oList2, oList1[oList1.selectedIndex].value, arrList);
    return true; }
    function clearDynaList(oList){
    for (var i = oList.options.length; i >= 0; i--){
    oList.options[i] = null; }
    oList.selectedIndex = -1; }
    function populateDynaList(oList, nIndex, aArray){
    for (var i = 0; i < aArray.length; i= i + 3){
    if (aArray[i] == nIndex){
    oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
    if (oList.options.length == 0){
    oList.options[oList.options.length] = new Option("[none available]",0); }
    oList.selectedIndex = 0; }
    function MM_callJS(jsStr) { //v2.0
      return eval(jsStr)
    //-->
    </script>
    </head>
    <body onload="MM_callJS('setDynaList(arrDL1)')">
    <form action="#" method="get" name="form1">
    <select name="selList1" onchange="MM_callJS('setDynaList(arrDL1)')">
      <?php
    do { 
    ?>
      <option value="<?php echo $row_sector['sector_code']?>"><?php echo $row_sector['sector_desc']?></option>
      <?php
    } while ($row_sector = mysql_fetch_assoc($sector));
      $rows = mysql_num_rows($sector);
      if($rows > 0) {
          mysql_data_seek($sector, 0);
          $row_sector = mysql_fetch_assoc($sector);
    ?>
    </select>
    </form>
    <form action="#" method="get" name="form2">
    <select name="selList2"></select>
    </form>
    </body>
    </html>
    <?php
    mysql_free_result($sector);
    mysql_free_result($rsList2);
    ?>
    The javascripts errors that I m getting are :
    Syntax error  test.php, line 20 character 1
      'arrDL1' is undefined  test.php, line 74 character 3
      'arrDL1' is undefined  eval code, line 1 character 1
    Note: I have bolded the lines where error is coming up.
    If more info is needed please tell.
    Please Help,
    Thanks in Advance

    You'd probably have to put a copy of the app on apex.oracle.com for a complete diagnosis, but you could maybe just check that the Source Used attribute for teh select list is set to 'Only when current value in session state is null' and not the 'Always' option.
    Regards,
    John.

  • Need a little JavaScript help with disabling a select list in a tabular frm

    Hello Folks
    Here's the scenario.
    I have a tabular form which, subject to the setting of one Select List, I want to disable/enable another.
    I have got this far and it will disable a text item but not a select list..
    This is in the HTML header section for the page...
    <script type="text/javascript">
    function test(pThis)
    var currIndex = $('select[name="'+pThis.name+'"]').index(pThis);
    if (pThis.value=='2') {
    $('input[name="f02"]')[currIndex].style.backgroundColor = "LightGrey";
    $('input[name="f02"]')[currIndex].disabled=true;
    The report region is defined as...
    SELECT apex_item.text(1, ir.iot_rebate_type_id) iot_rebate_type_id
    ,apex_item.select_list_from_lov_xl(2,ir.rebate_currency,'LOV_CURRENCY_CODES') rebate_currency
    FROM iot_rebate ir
    WHERE ir.iot_agreement_id = :P303_IOT_AGREEMENT_ID
    The iot_rebate_type_id column has an Column Element Attribute set to...
    onchange="javascript:test(this);"
    As I say, if I define the rebate currency as a text item, the javascript works fine.
    Can anyone offer any suggestions?
    Many thanks
    Simon
    Application Express 4.0.2.00.07

    Simon Gadd wrote:
    Hi Vikram.
    That's great.
    I have the relevant items being set to diabled & grey (and also the reverse of this if the driving select list is changed back).
    As this is being used in a Tabular form, if I am calling pre-existing records which should be displayed with two of the select lists disabled, can you point me in the right direction to show the relevent select lists as disabled when the records are returned from the database?If you are using apex_item API set the disabled property into p_attributes parameter conditionally using a case statement in you sql statement
    Another option is you can use some javascript to loop through the tabular form array that runs on the onload of the page.
    Finally, if some columns are disabled, this invaludates the MRU process on the page. Is there a way to submit the page with some fields in the disabled state?Do that as per Roel's suggestion for this issue.
    Any input/pointers much appreciated.
    Simon

Maybe you are looking for