Advanced Search

Results 1 to 2 of 2

Thread: Preset chained selects

  1. #1
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Preset chained selects

    1) Script Title:
    Chained Selects

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...ects/index.htm

    3) Describe problem:
    So my question is, is there a way to preset the select options via html, not js. So like lets say im getting values from a database and i want the select statements to be already set to what the values were in the database, and preferably i dont want any messy js so is it possible to do with just php/html? Thanks guys

  2. #2
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I found a solution, so if anyone for some reason ever wonders what I wondered, what I did was basically use php to add ", 1" to the end of the options i wanted to be preset, which basically makes them default, so then instead of including the script like you usually do in html, I did this:

    <script type="text/javascript">
    <?php

    $myFile = "script.js";
    $fh = fopen($myFile, 'r');
    $theData = fread($fh, filesize("script.js"));
    fclose($fh);
    $theData = str_replace("\"value\");", "\"value\", 1);", $theData);
    echo $theData;

    ?>
    </script>

    I don't know if it makes sense how i described it but you can study the code and I'm sure you'll figure out what i did

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •