Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7583775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:45:50+00:00 2026-05-30T18:45:50+00:00

Background: This page is a form that has a table to select permisson for

  • 0

Background:

This page is a form that has a table to select permisson for different users (Read only,editable)
For each selectbox ,the name is the id of users.

Question:

1)How can it put in a dialog using jquery?
as i googled found that the pop up box is not a new page as usual , but only a form in <div> element , I need to use datatable in this case so i can not simply do this.

2) How to retrieve the value after the pop up box closed?
For each selectbox ,the name is the id of users, i would like to get the userid and the permission setting for each users.

Thank you for kindly help

This is the add.php (upper level form)

<?
include("../connection/conn.php");
session_start();

if($_SERVER['REQUEST_METHOD'] == "POST"){

if (!isset($_POST['subscribe']))
$_POST['subscribe']=0;
if (!isset($_POST['unsubscribe']))
$_POST['unsubscribe']=0;

$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

try {

    $listName = $_POST['lname'];
    $listFromName = $_POST['fname'];
    $listReplyTo = $_POST['remail'];
    $listSubject = $_POST['sub'];
    $listRemindSub = $_POST['subscribe'];
    $listRemindUnSub = $_POST['unsubscribe'];
    $listReminder = $_POST['creminder'];

    $query="INSERT INTO list (ListID,ListName,FromName,ReplyTo,Subject,IsRemindSub,IsRemindUnSub,CreateDate,Reminder) VALUES ('',?,?,?,?,?,?,CURDATE(),?)";
    $stmt = $conn->prepare($query);


    $stmt->bindParam(1, $listName , PDO::PARAM_STR);
    $stmt->bindParam(2, $listFromName, PDO::PARAM_STR);
    $stmt->bindParam(3, $listReplyTo, PDO::PARAM_STR);
    $stmt->bindParam(4, $listSubject, PDO::PARAM_STR);
    $stmt->bindParam(5, $listRemindSub, PDO::PARAM_INT);
    $stmt->bindParam(6, $listRemindUnSub, PDO::PARAM_INT);
    $stmt->bindParam(7, $listReminder, PDO::PARAM_STR);

    $stmt->execute();


}
catch(PDOException $e)
    {
    die ($e->getMessage().'<a href="add.php"> Back</a>'); 
    $conn->rollBack();
    }


try {
    $lastID=$conn->lastInsertId();
    $query="INSERT INTO require_attributes (ReqID,ListID,Attribute,Tag) VALUES ('',$lastID,'Email','{email}')";
    $stmt = $conn->prepare($query);
    $stmt->execute();
    $query="INSERT INTO require_attributes (ReqID,ListID,Attribute,Tag) VALUES ('',$lastID,'FirstName','{fname}')";
    $stmt = $conn->prepare($query);
    $stmt->execute();
    $query="INSERT INTO require_attributes (ReqID,ListID,Attribute,Tag) VALUES ('',$lastID,'LastName','{lname}')";
    $stmt = $conn->prepare($query);
    $stmt->execute();
}
catch(PDOException $e)
    {
    die ($e->getMessage().'<a href="add.php"> Back</a>'); 
    $conn->rollBack();
    } 

try {
    $userID = $_SESSION['username'];
    $query="INSERT INTO user_list (UserID,ListID,UserListRights) VALUES (?,$lastID,'Edit')";
    $stmt = $conn->prepare($query);
    $stmt->bindParam(1, $userID, PDO::PARAM_STR);

    $stmt->execute();

}
catch(PDOException $e)
    {
    die ($e->getMessage().'<a href="add.php"> Back</a>'); 
    $conn->rollBack();
    }    


$conn = null;

?>
<div id="stylized" class="myform">
<div style="text-align:center;font-weight:bold;">You have created a list. By default Mail Address, First Name , Last Name is in your list. Add more field if you want. <a href='add.php'>Back</a></div>
<div class="spacer"></div>
</div>
<?
}else{?>


<!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>

<script src="../plugin/jquery-1.6.1.min.js"></script>
<script src="../plugin/jquery.validate.min.js"></script>
<script src="../plugin/jquery.form.js"></script>
<link rel="stylesheet" type="text/css" href="../style/form.css" />
<script>
function loadDialogBox() {'
    $("#myEmptyDiv").load("popup.php", function() {

      $("#myEmptyDiv").dialog({
         title: "Permission Setting",
         autoOpen: false,
         buttons: { "Submit" : submitDialogForm() }
      });
      $("#myEmptyDiv").dialog("open");
    });
}

$(function() { $("#openDialog").on('click', loadDialogBox); });

$(document).ready(function(){
$("#addlist").validate();
});
</script>

</head>
<body>
<div id="stylized" class="myform">
<form id="addlist" method="post" action="add.php" >
<h1>Create your new subscriber list</h1> 
<p>Create a new list before adding subscriber <label class="right"><em class="dot">*</em> indicates required</label></p>

<label><em class="dot">*</em> List name:
<span class="small">Add your list name</span>
</label>
<input id="lname" name="lname" class="required" />

<div class="spacer"></div>

<label>Reminder:
<span class="small">Remind the details of your list</span>
</label>
<textarea id="creminder" name="creminder" cols="52" ></textarea>

<div class="spacer"></div>

<p>Permission Setting ...</p>

<a id="openDialog" href="#">Permission Settings</a>
<label>Or open to other users</label> <input type="checkbox" class="checkbox" name="public" value="1">


<div class="spacer"></div>

<p>Email me when ...</p> 
<label>People subscribe</label> <input type="checkbox" class="checkbox" name="subscribe" value="1">
<label>People unsubscribe</label> <input type="checkbox" class="checkbox" name="unsubscribe" value="1">


<div class="spacer"></div>
<input class="submit" type="submit" name="submit" value="Submit"/>
<div class="spacer"></div>

</form>
<div class="spacer"></div>
</div>
<br><br><br>
<div id="stylized" class="myform">
<?
try{
$sql = '
    SELECT   *
    FROM     list,user_list
    WHERE    user_list.UserID=?
    AND list.ListID=user_list.ListID
';
$stmt = $conn->prepare($sql);
$stmt->execute(array($_SESSION['username']));
$result= $stmt->fetchAll();
$num_rows= $stmt->rowCount();
}
catch(PDOException $e)
    {
    die ($e->getMessage().'<a href="add.php"> Back</a>'); 
    }
$conn = null;
if ($num_rows == 0) {
    echo '<div style="text-align:center;font-weight:bold;">You have not created any list yet.</div>';}
else {
    echo '<h1>Your Subscriber List</h1> <p>You have created '.$num_rows.' list(s).</p>';
foreach ($result as $set) 
{
echo '<div style="font-weight:bold;">List Name : '.$set['FromName'].'</div><br>';
echo '<div style="font-weight:bold;">Subscriber : </div><br>';
echo '<div style="font-weight:bold;">Create Date : '.$set['CreateDate'].'</div><br>';
echo '<hr>';
}}
    ?>

<div class="spacer"></div>
</div>
</body>
</html>

<?
}
?>

This is the popup.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
      @import "../plugin/datatable/media/css/demo_page.css";
      @import "../plugin/datatable/media/css/demo_table.css";
    </style>
    <script type="text/javascript" src="../plugin/datatable/media/js/jquery.js"></script>
    <script type="text/javascript" src="../plugin/datatable/media/js/jquery.dataTables.js"></script>
    <script>

    function submitDialogForm() {
  $.post("add.php", $("#myEmptyDiv form").serialize(), function(data) {
     $("#yourUserIdDisplay").val(data.userId);
  });
}
    $(document).ready(function() {
    $('#viewSub').dataTable();
    } );
    </script>
    </head>
<body>
<?
include("../connection/conn.php");
session_start();
$sql =
    "SELECT  UserID,Name,Rights,Position
    FROM     user
    WHERE UserID != ?
    AND Rights != 'Admin'
    ";
$stmt = $conn->prepare($sql);
$stmt->execute(array($_SESSION['username']));
$num_rows= $stmt->rowCount();
if ($num_rows == 0)
echo "There is no another user in this system";
else{
$result = $stmt->fetchAll();
?>
<form>
<table width="100%" class="display" id="viewSub">
<thead>
<tr>
<th field="col1" width="40%">Name:</th>
<th field="col2" width="40%">Position:</th>
<th field="col2" width="20%">Permission:</th>
</tr>
</thead>
<tbody>
<?
foreach ($result as $set) 
{
    echo "<tr><td>".$set['Name']."</td><td>".$set['Position']."</td><td><select name=".$set['UserID']."><option value='default'>Not Share</option><option value='Read'>Read Only</option><option value='Edit'>Editable</option></select></td></tr>";
}
?>
</tbody> 
</table>
<div style='text-align:center'> <button id='save'>Confirm</button></div>
</form>
<?
}
?>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:45:52+00:00Added an answer on May 30, 2026 at 6:45 pm

    First, to load a page into a dialog from jQuery, try something like this:

    function loadDialogBox() {
        $("#myEmptyDiv").load("url-to-this-form.php", function() {
    
          $("#myEmptyDiv").dialog({
             title: "your dialog title",
             autoOpen: false,
             buttons: { "Submit" : submitDialogForm() }
          });
          $("#myEmptyDiv").dialog("open");
        });
    }
    

    Now you can load and open your form with a call to the loadDialogBox function. Maybe something like this:

    <a id="openDialog" href="#">Open Dialog</a>
    
    $(function() { $("#openDialog").on('click', loadDialogBox); });
    

    Then, create a submit function like so:

    function submitDialogForm() {
      $.post("submit-page.php", $("#myEmptyDiv form").serialize(), function(data) {
        // here you can parse your return data for userid or permission settings that come back from server
         $("#yourUserIdDisplay").val(data.userId);
      });
    }
    

    This will serialize the dialog form data and post it to your server.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with a table on it that has several thousand rows
Take a look at this page: http://pearl.tinderfields.com/ In IE6 the menu's background image loads
I have this simple Jsp page: <%@ page language=java import=java.awt.Color%> <% Color background =
Supposing I'm setting a background image for a web page in CSS like this:
I am working on a Silverlight application that has a Form that is supposed
I am working on a drupal site that has a form submit ajax call
I have a jQuery modal dialog that loads a different page on an iframe.
I am suppose to Create a form that gives the user 3 different options
I'm trying to automate a simple page that has a colorbox that loads an
I have a form with a few fieldsets. One fieldset has a table of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.