#16
  1. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    THANKS!!!!!!!!!!!!!!


    The code on this site has helped me to build dynamic listboxes where the second depends on the first. The data comes from DB2, via a bean. This was something I struggled with for several days and HAD to get sorted out!
    Thanks for the information
  2. #17
  3. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    script problem


    This is how my array is being setup by the script. I've been racking my brain trying to figure out why it's breaking it up like this. Please help me out.

    Thanks,

    Ed
    Code:
    var ar = new Array();
    ar[0]=new Array();
    ar[0][0]=new makeOption("Smobile
    ", "11");
    ar[1]=new Array();
    ar[1][0]=new makeOption("2.2CL
    ", "82");
    ar[1][1]=new makeOption("2.3CL
    ", "142");
  4. #18
  5. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    extension


    What extension do you use on the file to get it to work? .js or .php*
  6. #19
  7. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Re: extension


    That is, I want to use the php script in a file that already has a .js extension. How can I get it to run?
  8. #20
  9. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Neat Idea


    Normally I've put the javascript as static code in the page - this idea opens up a whole bunch more possibilities - the database could now 'write' (output) very dynamic pages with some slick menus.
    Thanks for the idea!
  10. #21
  11. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Good Work!


    This idea is simply great.
    But can anyone tell me how to do the reverse
    ie., exchange a value in javascript variable to a php variable.
    I tried but this method doesnt work.
    Code is like
    <?
    print "<script language=javascript>";
    print "var mn=5";
    $test = print "mn";
    print "</script>";
    ?>
    The $test variable is always assigned a value of 1(indicating successful execution of print statement)

    Any help is appreciated.
    Thanks in advance.

  12. #22
  13. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Nice article... too bad I found it too late


    Nice and neat, right to the point... I had to work out somthing similar to your example for the group members and my efforts ended with a PHP class (linked_select class) that creates 2 selects linked together from 2 related tables in MySQL (linked_select class can be found at http://phpclasses.upperdesign.com section databases)
  14. #23
  15. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    GREAT Idea-THANKS!!!!!


    I haven't tested the code....If it has bugs...no problem....its the idea I was looking for ...and now I found it.

    THANKS VERY VERY MUCH. KEEP UP THE GOOD WORK. Pay no attentions to the dumbass comments.
  16. #24
  17. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Re: Two menus same page?


    I came across the same problem with the JavaScript from:

    http://wsabstract.com/script/cut183.shtml

    I believe the problem is a HTML one as you can't have a form inside a form. The answer is I believe (although I haven't yet had a chance to try this out) is to have a new form for each drop down menu and then pass all the results to a hidden form.

    Actually I've had a search around while checking this and it seems quite a bit simpler than that see:

    http://freewarejava.com/ubb/Forum1/HTML/013891.html

    Dan
  18. #25
  19. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    PHP and Javascript Program Problem


    Hello,

    Do you have some experience on PHP and Javascript Programming ? There are some problem for me. Actually, I through Javascript program to get user input, and
    then pass to PHP program for examine the input data.

    When I run the program and select the A only after submit the form, but the result are $user_options[0] = D, $user_options[1] = , $user_select[2] = and
    $user_options[3] = . Why it should be $user_select[0]=A ? Because I chosen the A only ! Now I find out javascript program can't control PHP program. So
    $user_options[0] = D, because this program run at last !

    So do you know how to implement the javascript program data pass to PHP program ?

    Regard's
    Perrin


    Here is the program:
    ==================================================================================================== ====
    <?php
    session_register("user_options");
    ?>

    <?php

    $user_options; $action;

    switch($action) {
    case "submit":
    for($i=0 ; $i<5 ; $i++) {
    echo "user_options[$i] = $user_options[$i]";
    echo "<p>";
    }
    break;

    default:
    display_screen();
    break;
    }

    function display_screen() {

    global $user_options, $action;

    echo "<head>";
    echo "<title>Testing</title>";
    echo "</head>";
    echo "<body bgcolor=#FFFFFF text=#000000>";
    echo "<hr>";
    echo "<p>";
    echo "<form name=form1 method='get'>";
    echo "<input type=hidden name=action value='submit'>";

    ?>

    <table width="20%" border="1">
    <tr>

    <td>
    <select name="select1" size="4" >
    <option value="A">A
    <option value="B">B
    <option value="C">C
    <option value="D">D
    </select>
    </td>

    <td>
    &nbsp; &nbsp; <input type="button" value="-->" onClick="createOptions()">
    <p>
    </td>

    <td>
    <select name="select2" size="4">
    <option value="" >&nbsp;You Selected
    <option value="" >&nbsp;---------------
    </select>
    </td>

    </tr>
    </table>
    <hr>
    <br>
    <br>
    <p>
    <center>
    <p>

    <?
    //initial user_options data = "0"
    for($i=0 ; $i<5 ; $i++) {
    echo "user_options[$i] = ''";
    echo "<p>";
    }

    echo "<input type=Submit name=action value=submit onClick=\"ViewOptions()\">&nbsp; &nbsp;";
    echo "<input type='reset' name='Submit2' value='Reset'>";
    ?>

    </center>
    </P>
    </form>
    </body>

    <script>
    <!--
    function ViewOptions() {

    alert("debug1 user_options = <? echo "$user_options[0]"; ?>");
    ?>
    var item = document.form1.select2.options.length;

    if(item > 2) {
    <? $j=0; ?>
    for (var i=2; i<item; i++) {
    var temp = document.form1.select2.options[i].text;
    switch(temp) {
    case "A":
    alert("debug2 set user_options[<?echo "$j";?>] = A");
    alert("debug3 user_options[<?echo"$j";?>] = <?echo "$user_options[$j]"; ?>");
    <? $user_options[$j] = 'A'; ?> The PHP program can't be controlled by Javascript switch case"A"
    break;

    case "B":
    alert("debug2 set user_options[<?echo "$j";?>] = B");
    alert("debug3 user_options[<?echo"$j";?>] = <?echo "$user_options[$j]"; ?>");
    <? $user_options[$j] = 'B'; ?>
    break;

    case "C":
    alert("debug2 set user_options[<?echo "$j";?>] = C");
    alert("debug3 user_options[<?echo"$j";?>] = <?echo "$user_options[$j]"; ?>");
    <? $user_options[$j] = 'C'; ?>
    break;

    case "D":
    alert("debug2 set user_options[<?echo "$j";?>] = D");
    alert("debug3 user_options[<?echo"$j";?>] = <?echo "$user_options[$j]"; ?>");
    <? $user_options[$j] = 'D'; ?> // So the last time run it, due to $user_options[0] = D
    break;
    }
    <? $j++; ?>
    }
    }
    alert("debug END");
    }
    //-->
    </script>

    <?
    }
    ?>



    <script language="JavaScript1.1">
    <!--
    function createOptions(){

    sel1 = document.form1.select1;
    sel2 = document.form1.select2;
    var num = sel1.selectedIndex;
    var option = new Option(sel1.options[num].text);
    var item = sel2.options.length;

    sel2.options[item] = option;
    sel1.selectedIndex = 10000;
    }
    //-->
    </script>


  20. #26
  21. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Just what I need


    This code seems to be exactly what I am looking for. I am already using MySQL and
    PHP in my envronment, as was looking for
    aa method to build JavsScript arrays with PHP.

    I shall let you know how I get on

    John
  22. #27
  23. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Re: extension


    I would put the php code in a .php file which includes the .js file with script tags.
  24. #28
  25. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Re: Two menus same page?


    It seems your problem is with the PHP code.
    You need to call
    mysql_data_seek($result,0);
    to reset the result set so that the while
    loop can run again without a requery.

    I hope that is helpful.
  26. #29
  27. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    WHERE IS THE NEXT ARTICLE


    Where the fruitcakes is the next article the author so kindly said was comming :

    "The next challenge will be passing multiple values to the form processings
    will be done using a combination of JavaScript and PHP, and will be the focus
    of a seperate upcoming article. "

    I tried emailing the author but the domains dropped off the face of the internet - can someone else perhaps do a tutorial for this as this has got me stumped!

    Cheers!!
    Paul.
  28. #30
  29. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Re: WHERE IS THE NEXT ARTICLE


    There an article at
    http://www.devshed.com/Server_Side/PHP/Dynamic_Menu/page1.html.
    you should read.

    I found it very helpfull.

    ii

IMN logo majestic logo threadwatch logo seochat tools logo