js| Background | Data The method is already in the past, where the key is also from the altar, I just digested it and then wrote it back more fully. The announcement is just a hope that more beginners can learn something from it. If you have any comments on the code, you can leave a message, but please do not do personal attacks, I am a bird can only write this thing, every veteran has such a process.
In view of the time issue, the submission section of the code uses a traditional form post, and if you like, you can add the corresponding script according to the load process, but it seems only
can use get. Listen to the fact that XML can actually be really refreshing, and if anyone has a wish to lend a look.
Thanks to the QQ group in the Blue Sword Snow Fox and Shelly Water in JS to give help, but also the novice can write their own functions of the code posted to everyone together to learn research.
Last attached demo address: http://lfox0002.dns0755.net/text_input.php please enjoy the hack of other people's robots, and attach a demo to let friends know the code faster.
<?php
/*
Affirmed
------------------------------
The demo file describes in detail the method of using js+php to do similar refreshing read writes to a database
February 14, 2004
by L.fox
*/
Header ("Cache-control:no-store, no-cache,must-revalidate"); These two lines can be canceled to save the file as HTML
echo $_post["name1"]; I did it for #123.
?>
<meta http-equiv= "Content-type" content= "text/html; charset=?????? " >
<title> retrieve data from MySQL to edit and save according to number [demo]</title>
<script language= "JavaScript" id= "LOADDATASRC" ></script>
<style>
Body {
font-family: "Verdana", "Arial", "Helvetica", "Sans-serif";
font-size:12px;
line-height:17px;
Scrollbar-base-color: #BBBBBB;
Scrollbar-shadow-color: #BBBBBB;
Scrollbar-highlight-color: #FFFFFF;
Scrollbar-3dlight-color: #000000;
Scrollbar-darkshadow-color: #000000;
Scrollbar-arrow-color: #FFFFFF;
}
Table {
border:0;
font-size:12px;
Cursor:default;
}
TD {
Text-align:left;
height:20;
}
Input {
width:100;
height:18;
border:0px solid #666666;
Text-align:left;
}
</style>
<script>
var objinput = null;
var objtd = null;
var num =null;
function Autoedit (obj,id)
{
if (objinput = null)
{
OBJTD = obj;
obj.innerhtml = "<input size=\" 10\ "maxlength=\" 10\ "type=\" text\ "value=\" "+ Obj.innertext +" \ "
Id=\ "objinput\" onblur=\ "objtd.innertext=this.value; LoadData (objtd.innertext,num); objinput=null;\ "style=\" overflow:
Visible;border:none;background-color: #EFEFEF ">";
Objinput = document.getElementById ("Objinput");
Objinput.focus ();
}
}
<?php
Header ("Cache-control:no-store, no-cache,must-revalidate");
Include ("Obj/financial_obj_free.inc"); The content in this file is a statement that connects to MySQL.
$str =$_get["Action"];
$num =$_get["num"];
if ($str = = "Outputdata") outputdata ();
Else
{
Linkdata ("financial", 1);
$sql = "SELECT * from table where id= ' $str '";
if ($query =mysql_query ($sql))
{
$temdata =mysql_fetch_row ($query); See if it is empty, if it is attached to the value to avoid JS error.
if (strlen ($temdata [2]) <1| | $temdata [2]== "] $temdata [2]=];
$temdata [2]=htmlspecialchars ($temdata [2]);
if (strlen ($temdata [3]) <1| | $temdata [3]== "] $temdata [3]=];
$temdata [3]=htmlspecialchars ($temdata [3]);
if (strlen ($temdata [5]) <1| | $temdata [5]== "] $temdata [5]=];
$temdata [5]=htmlspecialchars ($temdata [5]);
}
Else
{
$temdata [2]= $temdata [3]= $temdata [5]= query failed];
}
Switch ($num)//This is mainly used for inspection from the first few columns (lines) passed over. Note that the value of the variable should correspond to the ID value of input. Otherwise, an error
{
Case 1:
$diva = "Name1";
$DIVB = "Type1";
$DIVC = "Date1";
Break
Case 2:
$diva = "Name2";
$DIVB = "type2";
$DIVC = "Date2";
Break
Default
$diva = "Name1";
$DIVB = "Type1";
$DIVC = "Date1";
Break
}
Determine node, output $TEMDATA[X] to node $divx;
echo "document.getElementById" (". $diva."). Innerhtml= ' ". $temdata [2]." '; ";
echo "document.getElementById" (". $divb."). Innerhtml= ' ". $temdata [3]." '; ";
echo "document.getElementById" (". $divc."). Innerhtml= ' ". $temdata [5]." '; ";
}
function Outputdata ()//This can be written into the database if you change it to a SQL statement
{
echo "Output data as follows, change to SQL statement and then save it";
echo "Number 1=". $_post["Name1"]. " <br> ";
echo "Number 2=". $_post["Name2"]. " <br> ";
echo "Name 1=". $_post["Type1". " <br> ";
echo "Name 2=". $_post["type2". " <br> ";
echo "Date 1=". $_post["Date1". " <br> ";
echo "Date 2=". $_post["Date2". " <br> ";
echo "Quantity 1=". $_post["NUM1"]. " <br> ";
echo "Quantity 2=". $_post["num2"]. " <br> ";
echo "<a href=\" Text_input.php\ "> Return </a>";
}
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.