Select option to dialog modal form mishap

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Select option to dialog modal form mishap

shayne.kellogg
I've spent the past few days trying out different variations of ways to get what I thought was a rather simple idea but has turned into a headache. So here it is in bits:

1. Mysql/PHP populated drop-down box with a list of items.
2. Take the selected item's value
3. Pass value to dialog modal form
4. Use passed value to populate the title and a hidden input
5. Post data to DB then return.

Essentially I want to have a drop-down box filled with lets say users from a database, then when I select a user from the drop-down a dialog form opens allowing me to rename, change password, and user lvl of the user selected from the drop-down.

Any thoughts?

Here's the relevant code:
JS:

        $(document).ready(function(){

           var modusername = $("#modusername" ),
               moduserlink = $("#moduserlink" ),
               mainmenu = $( "#mainmenu" ),
               enews = $( "#enews" ),
               euser = $( "#euser" ),
               allUserMenuFields = $( [] ).add( usermenu ).add( modusername ).add( moduserlink );


           $("#eusermenu").dialog({
              autoOpen: false,
              modal: true,
              resizable: false,
              title: "Edit User Menu Item: " + bob ,
              buttons: {
                  "Edit Menu Item": function() {
                     $.post("admin.php?OMG=usermenu", {usermenu: usermenu, modusername: modusername, moduserlink: moduserlink}, function(data){alert("Data loaded: " + data)});
                     },
                  Cancel: function() {
                    $( this ).dialog( "close" );
             }
              },
              close: function() {
                allUserMenuFields.val( "" );
            }

           });

           $("#umsub").click().submit(function(){
               var bob = $(this).attr('value')
               $( "#eusermenu" ).dialog( "open" );
               return false;
             });


        });


<br />

HTML/PHP:

#                $body = "<p>

Edit Website

<br />";
# Further down the page......          
# <div id="eusername" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable">
                  <div class="ui-dialog-content ui-widget-content">
                      <form action="admin.php?OMG=usermenu" method="post" name="usermenu">Rename to:<input type="text" name="modusername" id="modusername"><br />New URL<input type="text" name="moduserlink" id="moduserlink"></form>
                  </div>
           </div>
Edit user menu items: <select name=\"usermenu\" id=\"usermenu\">"; //--------Body Start Tag----//

                $p = 0;
                while ($p < $num1a) {

                    $mname1a = mysql_result($result1a, $p, "name");

                    $body.= "<option value=\"". $mname1a ."\" title=\"". $mname1a ."\">". $mname1a ."</option>";

                    $p++;
                }

                $body.= "</select>
<input type=\"submit\" id=\"umsub\" value=\"Edit Item\"></form>