使用Javascript更改框的输入值

时间:2013-08-02 17:09:06

标签: javascript php input html-table

我有一个用于生成电子邮件模板的表单。在页面底部,我有一个表格,显示电子邮件名称,以及哪些部门有权使用它。最终我想要发生的是让页面底部的电子邮件名称像按钮一样。当用户单击电子邮件名称时,它将从数据库中获取这些值并将它们传递到相应的输入字段。下面是我当前PHP代码的示例。如果有人可以提供建议甚至是一个例子,我将不胜感激。

这是电子邮件模板设置的表单:

<form id="Email" name="Email" method='post' action="<?php echo htmlspecialchars($_SERVER['PHP']);?>">
<fieldset style="width: auto; height: auto;">
<legend class="legend1"><h2>&nbsp; Manage E-Mails &nbsp;</h2></legend>
<table width="100%" style="text-align:center">
<tr>
<td width="60%" style="text-align: left;">
<input type="text" id="name" name="name" placeholder="Email Template Name" value="" maxlength="100" style="width: 250px; height: 20px;"/>
<input type="radio" name="from" id="from" value="user" />Send From User
</td>
</tr>
<tr>
<td style="text-align: left;">
<input type="text" style="width:250px; height: 20px; visibility: hidden;" />
<input type="radio" name="from" id="from" value="department" />Send From Department
</td>
</tr>
<tr>
<td style="text-align: left;">
<input type="text" id="To" name="To" placeholder="To: " value="" maxlength="250" style="width: 250px; height: 20px;"/>
<input type="checkbox" name="user" id="user" value="YES" />Autocopy User
<?php echo "&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;";?><input type = "checkbox" name="escalate" id="escalate" value="YES" />Make Escalated Email Only
</td>
</tr>
<tr>
<td style="text-align: left;">
<input type="text" id="CC" name="CC" placeholder="CC: " value="" maxlength="100" style="width: 250px; height: 20px;"/>
<input type="checkbox" name="customer" id="customer" value="YES" />Autocopy Customer
</td>
</tr>
<tr>
<td style="text-align: left;">
<input type="text" id="BCC" name="BCC" placeholder="BCC: " value="" maxlength="100" style="width: 250px; height: 20px;"/>
<input type="checkbox" name="additional" id="additional" value="YES" />Allow Additional Email Address(es)
</td>
</tr>
<tr>
<td colspan=2 style="text-align: left;">
<input type="text" id="subject" name="subject" placeholder="Subject " value="" maxlength="100" style="width: 400px; height: 20px;"/> 
<a href="#" onclick="window.open('includes/adminpages/keywords.php', 'newwindow', 'width=500, height=400'); return false;">Keywords</a>
</td>
</tr>
<tr>
<td style="text-align: left;">
<textarea  name="content" maxlength="3000" cols="100" rows="12"></textarea>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Submit" style="float: left;">
</fieldset>
</form>

这是允许用户更新电子邮件所属部门的表单。这将显示电子邮件名称。我希望电子邮件名称可以点击,并将信息生成回上面的表格。

<form id = "Display_Email" name="Display_Email" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP']);?>">
<?php
$get_business = mysql_query("SELECT bus_name, bus_id FROM business where bus_id = '{$_SESSION['bus_id']}'");
while(($business = mysql_fetch_assoc($get_business)))
{
echo '
<h3>'.$business['bus_name'].'</h3>
<table class="departments">
<tr>
<th scope="col" style="width: 175px;">Email Name</th>
';
$get_depts = mysql_query("SELECT dept_name FROM depts where bus_id = '{$_SESSION['bus_id']}'");
while(($department = mysql_fetch_assoc($get_depts)))
{
    echo '
    <th scope="col" style="width: 175px;">'.$department['dept_name'].'</th>
    ';
}
echo '
</tr>
';
$get_emails = mysql_query("SELECT id, email_name from emails where bus_id = '{$_SESSION['bus_id']}' ORDER BY email_name ASC");
while(($email = mysql_fetch_assoc($get_emails)))
{
    echo '
    <tr>
    <td>'.$email['email_name'].'</td>
    ';
    $get_depts = mysql_query("SELECT dept_name, dept_id FROM depts where bus_id = '{$_SESSION['bus_id']}'");
    while(($department = mysql_fetch_assoc($get_depts)))
    {
        $get_email_dept = mysql_query("SELECT dept_id from emails where id = '{$email['id']}'");
        while(($email_dept = mysql_fetch_assoc($get_email_dept)))
        {
            $departments = explode(",", $email_dept['dept_id']);
            if(in_array($department['dept_id'], $departments, TRUE))
            {
                echo '<input type="hidden" name="Email_Box[]" value="0">';
                echo '<td><input type="checkbox" name="Email_Box[]" value="'.$department['dept_id'].'" checked="checked""></td>';
            }
            else
            {
                echo '<input type="hidden" name="Email_Box[]" value="0">';
                echo '<td><input type="checkbox" name="Email_Box[]" value="'.$department['dept_id'].'"></td>';
            }
        }
    }
    echo '
    </tr>
    ';
}
echo '
    </table>
    ';
}
?>
<input type="submit" name="Email_Submit" value="Submit" style="float: left;"/>
</form>

0 个答案:

没有答案