Skip to content

Commit

Permalink
Automatically sets focus to new code input in label list. Also checks…
Browse files Browse the repository at this point in the history
… that there is a code before committing "Add" to db.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@938 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Feb 24, 2004
1 parent 8d75153 commit 07281d2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions admin/labels.php
Expand Up @@ -310,7 +310,7 @@
echo "\t\t\t\t<tr>\n"
."\t\t\t\t<form method='post' action='labels.php'>\n"
."\t\t\t\t\t<td>\n"
."\t\t\t\t\t<input type='text' $slstyle name='code' size='5'>\n"
."\t\t\t\t\t<input type='text' $slstyle name='code' size='5' id='addnewlabelcode'>\n"
."\t\t\t\t\t</td>\n"
."\t\t\t\t\t<td>\n"
."\t\t\t\t\t<input type='text' $slstyle name='title' size='35'>\n"
Expand All @@ -321,6 +321,11 @@
."\t\t\t\t\t<td>\n"
."\t\t\t\t\t</td>\n"
."\t\t\t\t</tr>\n";
echo "<script type='text/javascript' language='javascript'>\n"
. "<!--\n"
. "document.getElementById('addnewlabelcode').focus();\n"
. "//-->\n"
. "</script>\n";
}
else
{
Expand Down Expand Up @@ -426,10 +431,13 @@ function modanswers($lid)
switch($_POST['method'])
{
case _ADD:
$query = "INSERT INTO {$dbprefix}labels (lid, code, title, sortorder) VALUES ($lid, '{$_POST['code']}', '{$_POST['title']}', '{$_POST['sortorder']}')";
if (!$result = mysql_query($query))
if (isset($_POST['code']) && $_POST['code'])
{
echo "<script type=\"text/javascript\">\n<!--\n alert(\""._LB_FAIL_INSERTANS." - ".$query." - ".mysql_error()."\")\n //-->\n</script>\n";
$query = "INSERT INTO {$dbprefix}labels (lid, code, title, sortorder) VALUES ($lid, '{$_POST['code']}', '{$_POST['title']}', '{$_POST['sortorder']}')";
if (!$result = mysql_query($query))
{
echo "<script type=\"text/javascript\">\n<!--\n alert(\""._LB_FAIL_INSERTANS." - ".$query." - ".mysql_error()."\")\n //-->\n</script>\n";
}
}
break;
case _AL_SAVE:
Expand Down

0 comments on commit 07281d2

Please sign in to comment.