Jump to content

tshing70

Members
  • Posts

    15
  • Joined

  • Last visited

tshing70's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. If i don't use the<input type="hidden" name="page_mode" value="add_user"> method change to <a href = 'member.php'> method, how it look like??? Can give some example??? thank
  2. Sorry about that, haven't change it...heheAnd also , this code i cant add new data to my index.php...can see what is the problem??
  3. Sry, but i quite confuse... can help check my code??index.php<HTML><HEAD><TITLE>List</TITLE></HEAD> <BODY> <table border="1" width"400"><tr> <td>Id</td><td>Name</td><td>Gender</td><td>Dob</td><td>Address</td><td>State</td><td>Ismember</td></tr> <?php $link=mysql_connect("localhost","root",""); $db=mysql_select_db("member_db", $link); $querry="SELECT * FROM newmember"; $result = mysql_query($querry); $i = 1; while ( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) ?> <tr> <td><?php echo $row['P_Id']; ?></td> <td><?php echo $row['Name']; ?></td> <td><?php echo $row['Gender'];?></td> <td><?php echo $row['Dob'];?></td> <td><?php echo $row['Address']; ?></td> <td><?php echo $row['State'];?></td> <td><?php echo $row['Ismember'];?></td> <td>[<a href =editform.php?id=<?php echo $row['P_Id]?>">Edit</a>] [<a href =deleteform.php?id=<?php echo $row['P_Id]?>">Delete</a>] </td> </tr> <a href = "member.php?id=<?php echo $row['P_Id']?>">Add New Member</a> </TABLE></BODY></HTML> member.php<HTML> <?php if (isset($_POST['submit'])){$name = $_POST['Name'];$gender = $_POST['Gender'];$dob = $_POST['Dob'];$address = $_POST['Address'];$state = $_POST['State'];$ismember = $_POST['Ismember']; $link=mysql_connect("localhost","root","");$db=mysql_select_db("member_db", $link); $sql = "INSERT INTO newmember (Name,Gender,Dob,Address,State,Ismember)VALUES ('','$name','$gender','$dob','$address','$state','$ismember')";$result = mysql_query($sql);if($result){echo("<br>Input data is sucess");}else{echo("<br>Input data is fai;l");}}?><HEAD><TITLE>Form</TITLE> <script type="text/javascript" src="tcal.js"></script><link rel="stylesheet" type="text/css" href="tcal.css" /></HEAD> <BODY> <FORM ACTION ="index.php" method="POST"> <table border='1'><tr><td>Name</td><td><Input type ="text" NAME="name"></td></tr> <tr><td>Gender</td><td><Input type = "radio" NAME="gender" VALUE="M">Male<Input type = "radio" NAME="gender" VALUE="F">Female</td></tr> <tr><td>D.O.B</td><td><Input type = "date" NAME="dob" class="tcal" value=""></td></tr> <tr><td>Address</td><td><textarea NAME = "address" ROWS = "4" COLS="30"></textarea></td></tr> <tr><td>State</td><td><select name = "state"><option><option>SABAH<option>SARAWAK<option>KUCHING<option>SIBU<option>MIRI</select></td></tr> <tr><td>Is Member</td><td><input type ="checkbox" name ="ismember" value="Yes"></td></tr> <tr><td></td><td><input type ="reset" NAME = "reset" value="Clear"><input type ="submit" NAME ="submit" value="Save"></td></tr></FORM></BODY></HTML> thank a lot.....
  4. I have a lndex.php to show the data, and Add , Edit text link to member.php....but how can i do the ADD and EDIT in one form???anyone can provide some example code???
  5. thank for reply, actually my error is thiswhen i go in the edit.phpI got newmember and collection table at 1 form, both work fine will show the info,but i add some info to collection table, which is add.php code to add the info, then back to edit.php form, the collection table work fine, successful add the info, but my newmember table completely error, show the Undefined index: id ,date, genderi believe maybe is add.php return variable got some wrong, but i can't figure out .....
  6. Hi guys, i got a question again.....thank for help anyway~ Ok, i have two table in edit.php which is newmember and collection, newmember is use too edit user info such as name, gender etc,collection is use too add date, amount and references no, WHEN I SUCCESSFUL ADD THE INFO AT COLLECTION TABLE, IT GOES BACK TO EDIT.PHPTHE NEWMEMBER TABLE BEEN ERROR SHOW ME Undefined index: id in C:\wamp\www\edit.php on line 16Undefined variable: gender in C:\wamp\www\edit.php on line 63 Call Stack #TimeMemoryFunctionLocation 11.7753382928{main}( )..\edit.php:0 " name="gender"/>Undefined variable: dob in C:\wamp\www\edit.php on line 65 Call Stack #TimeMemoryFunctionLocation 11.7753382928{main}( )..\edit.php:0 " name="dob" class="tcal"/>etc.... BUT MY COLLECTION TABLE WORK FINE, ONLY NEWMEMBER TABLE ERROR, WAT IS THE PROBLEMEDIT.PHP<center><html><head><title>Edit Form</title><link rel="stylesheet" type="text/css" href="tcal.css" /><script type="text/javascript" src="tcal.js"></script></head><body><?php$con = mysql_connect("localhost","root","");if (!$con){die('Could not connect: ' . mysql_error());} $id = $_GET["id"]; mysql_select_db("member_db", $con); $sql = "SELECT * FROM newmember Where P_Id=$id";$query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ $id = $row['P_Id'];$name = $row['Name'];$gender = $row['Gender']; $dob = $row['Dob'];$address = $row['Address'];$state = $row['State']; }mysql_free_result($query);?> <form action="update.php" method="post"><table width="250" border="1"> <tr valign="top"><td style="background-color:white;width:100px;text-align:top;"> Id<p>Name<p>Gender<p>Dob<p>Address<p>State</td><td style="background-color:#EEEEEE;height:200px;width:1000px;text-align:top;"><p><input type="text" value="<?php echo $id;?>" name="id" disabled/><p><input type="text" value="<?php echo $name;?>" name="name"/><p><input type="text" value="<?php echo $gender;?>" name="gender"/><p><input type="text" value="<?php echo $dob;?>" name="dob" class="tcal"/><p><input type="text" value="<?php echo $address;?>" name="address"/><p><input type="text" value="<?php echo $state;?>" name="state"/><p><input type = "submit" value="EDIT"/></table></form></body></html> <FORM method ="GET" action = "add.html"><input type = "submit" value = "Add"> <?php$con = mysql_connect ("localhost","root","");if (!$con){die('Could not connect: ' .mysql_error());}mysql_select_db("member_db", $con); $result = mysql_query("SELECT * FROM collection"); echo "<table border ='1'><tr><th>Id</th><th>Date</th><th>RefNo</th><th>Amount</th></tr>"; while($row = mysql_fetch_array($result)){echo "<tr>";echo "<td>" . $row['C_Id'] ."</td>";echo "<td>" . $row['date'] ."</td>";echo "<td>" . $row['refno'] ."</td>";echo "<td>" . $row['amount'] ."</td>";echo ("<td><a href=\"edit1.php?id=$row[C_Id]\">Edit</a></td>");echo ("<td><a href=\"delete1.php?id=$row[C_Id]\">Delete</a></td></tr>");} echo "</table>"; mysql_close($con); ?></FORM> ADD.php<?php $con = mysql_connect("localhost","root","");if (!$con){die('Could not connect: ' . mysql_error());} mysql_select_db("member_db", $con); $sql="INSERT INTO collection (date, refno, amount) VALUES ('$_POST[date]','$_POST[refno]','$_POST[amount]')"; if (!mysql_query($sql,$con)){die('Error: ' . mysql_error());}echo "1 record added";echo "<br>";echo "<a href='edit.php'>Back to Edit page</a>"; mysql_close($con);?> Thank for finish this long code, thank to everyone thank you~~~
  7. tshing70

    Help Help....

    thank for the reply, i will have a look later, again, thank~~
  8. tshing70

    Help Help....

    I have a member.php that for user input data, such as name, gender,dob etc...When i click save button, it will save to listing.php, inside listing.php store the information that user input, also a EDIT and DELETE button.Here is the point,When i click edit button, it goes to edit.php, inside edit.php, it have two table which is newmember and collection, inside newmember table, it use to edit the info that user insert,inside collection table, it able to add,delete,and edit...it contain date, referenceno and amount.... I wish when i click the edit button in edit.php, the collection table will focus on the member that i click...For example,when i click the edit.php member name is Andy, then the collection table only show Andy collection table,If other member name is Emandy, it will show only for Emandy collection table.Hope anyone can help me, many thank
  9. I have a table name collection withc_id int PK AUTO_INCREMENT,memberid int FK,date date,amount Numeric (12,2),refno VARCHAR(20), my FK references to my 1st table PK, name P_Id I want to add date, amount and refno,but when i click add it show me INSERT INTO collection (date, refno, amount) VALUES ('03/07/2012','345','234')Error: Cannot add or update a child row: a foreign key constraint fails (`member_db`.`collection`, CONSTRAINT `collection_ibfk_1` FOREIGN KEY (`memberid`) REFERENCES `newmember` (`P_Id`)) Anyone help pls.... Add.html<html><head><title>Add Info</title><link rel="stylesheet" type="text/css" href="tcal.css" /><script type="text/javascript" src="tcal.js"></script></head><body><form action = "add.php" method="post"><center><table width="250" border="1"><tr valign="top"><td style="background-color:white;width:100px;text-align:top;"><p>Date<p>Reference No<p>Amount</td><td style="background-color:#EEEEEE;height:200px;width:1000px;text-align:top;"><input type ="date" name="date" class="tcal" value=""/><p><input type ="text" name="refno"><p><br><input type ="number" name="amount"><p><input type ="submit" value="Add"></td></tr></form></table></center></body></html> Add.php<?php$con = mysql_connect("localhost","root","");if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("member_db", $con);$sql="INSERT INTO collection (date, refno, amount)VALUES ('$_POST[date]','$_POST[refno]','$_POST[amount]')";echo $sql;if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";echo "<br>";echo "<a href='edit.php'>Back to Edit page</a>";mysql_close($con);?>
  10. Nop, i didn't chg all of the code, it ok, i try to redo again~~Thank for you help
  11. Well.....when i add <?php echo row['P_Id'];?>"> full of this.....it show me this funny wordParse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\edit.php on line 33
  12. I was trying to edit form data using php, when i click the edit text, it show me the edit form, but the input text show me <? echo and does't show me the information that i wish to edit....what is the error below the code?? listing.php code<CENTER><?php$con = mysql_connect ("localhost","root","");if (!$con){die('Could not connect: ' .mysql_error());}mysql_select_db("member_db", $con); $result = mysql_query("SELECT * FROM newmember"); echo "<table border='1'><tr><th>Id</th><th>Name</th><th>Gender</th><th>DOB</th><th>Address</th><th>State</th><th>Is Member</th></tr>"; while($row = mysql_fetch_array($result)){echo "<tr>";echo "<td>" . $row['P_Id'] ."</td>";echo "<td>" . $row['Name'] ."</td>";echo "<td>" . $row['Gender'] ."</td>";echo "<td>" . $row['Dob'] ."</td>";echo "<td>" . $row['Address'] . "</td>";echo "<td>" . $row['State'] . "</td>";echo "<td>" . $row['Ismember'] . "</td>";echo ("<td><a href=\"edit.php?id=$row[P_Id]\">Edit</a></td>");echo ("<td><a href=\"delete.php?id=$row[P_Id]\">Delete</a></td></tr>");}echo "</table>"; mysql_close($con);?></CENTER> Edit.php code<html><head><title>Edit Form</title></head><body><table><tr><td align="center">EDIT DATA</td></tr><tr><td><table border="1"><?$con = mysql_connect("localhost","root","");if (!$con){die('Could not connect: ' . mysql_error());} mysql_select_db("member_db", $con); $id=$_GET['id'];$order = "SELECT * FROM newmember WHERE P_Id=$id";$result = mysql_query($order);$row = mysql_fetch_array($result);?> <form method="Post" action="update.php"><input type="hidden" name="id" value="<? echo "row['P_Id']"?><tr><td>Name</td><td><input type="text" name="name" value="<? echo "$row['Name']"?></td></tr><tr><td>Gender</td><td><input type="text" name="gender" value="<? echo "$row['Gender']"?></td></tr><tr><td>Address</td><td><input type="text" name="address" value="<? echo "$row['Address']"?></td></tr><tr><td>DOB</td><td><input type="text" name="dob" value="<? echo "$row['Dob']"?></td></tr><tr><td>State</td><td><input type="text" name="state" value="<? echo "$row['State']"?></td></tr><tr><td align="right"><input type = "submit" name="submit value" value="Edit"></td></tr></form></table></td></tr></table></body></html> UPDATE.php<? $con = mysql_connect ("localhost","root","");if (!$con){die('Could not connect: ' .mysql_error());}mysql_select_db("member_db", $con); $order = "UPDATE newmember SET name='$name', gender='$gender', address='$address', dob='$dob', state='$state', WHERE P_Id=$id";mysql_query($order);header("location:listing.php");?> i sorry about the long code, appreciated you guys finish reading it....thank a lot
  13. It work, thank you so much
  14. I want to delete the data when i click the delete text, but it does't work, any idea???This is my listing,php<CENTER><?php$con = mysql_connect ("localhost","root","");if (!$con){die('Could not connect: ' .mysql_error());}mysql_select_db("member_db", $con); $result = mysql_query("SELECT * FROM newmember"); echo "<table border='1'><tr><th>Id</th><th>Name</th><th>Gender</th><th>DOB</th><th>Address</th><th>State</th><th>Is Member</th></tr>"; while($row = mysql_fetch_array($result)){echo "<tr>";echo "<td>" . $row['P_Id'] ."</td>";echo "<td>" . $row['Name'] ."</td>";echo "<td>" . $row['Gender'] ."</td>";echo "<td>" . $row['Dob'] ."</td>";echo "<td>" . $row['Address'] . "</td>";echo "<td>" . $row['State'] . "</td>";echo "<td>" . $row['Ismember'] . "</td>";echo ("<td><a href=\"editinfo.php?id=$row[P_Id]\">Edit</a></td>");echo ("<td><a href=\"delete.php?id=$row[P_Id]\">Delete</a></td></tr>");}echo "</table>"; mysql_close($con);?></CENTER> My delete.php <?php $con = mysql_connect ("localhost","root","");if (!$con){die('Could not connect: ' .mysql_error());}mysql_select_db("member_db", $con); $order = "DELETE FROM newmember WHERE P_id='$id'"; mysql_query($order); header("location:listing.php");?> untitled.bmp
  15. I try to insert the date to mysql, the format it show me is 00-00-0000 wat is the problem? // default settins - this structure can be moved in separate file in multilangual applicationsvar A_TCALCONF = {'cssprefix' : 'tcal','months' : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],'longwdays' : ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],'yearscroll' : true, // show year scroller'weekstart' : 0, // first day of week: 0-Su or 1-Mo'prevyear' : 'Previous Year','nextyear' : 'Next Year','prevmonth' : 'Previous Month','nextmonth' : 'Next Month','format' : 'm/d/Y' // 'd-m-Y', Y-m-d', 'l, F jS Y'}; var A_TCALTOKENS = [// A full numeric representation of a year, 4 digits{'t': 'Y', 'r': '19\\d{2}|20\\d{2}', 'p': function (d_date, n_value) { d_date.setFullYear(Number(n_value)); return d_date; }, 'g': function (d_date) { var n_year = d_date.getFullYear(); return n_year; }},// Numeric representation of a month, with leading zeros{'t': 'm', 'r': '0?[1-9]|1[0-2]', 'p': function (d_date, n_value) { d_date.setMonth(Number(n_value) - 1); return d_date; }, 'g': function (d_date) { var n_month = d_date.getMonth() + 1; return (n_month < 10 ? '0' : '') + n_month }},// A full textual representation of a month, such as January or March{'t': 'F', 'r': A_TCALCONF.months.join('|'), 'p': function (d_date, s_value) { for (var m = 0; m < 12; m++) if (A_TCALCONF.months[m] == s_value) { d_date.setMonth(m); return d_date; }}, 'g': function (d_date) { return A_TCALCONF.months[d_date.getMonth()]; }},// Day of the month, 2 digits with leading zeros{'t': 'd', 'r': '0?[1-9]|[12][0-9]|3[01]', 'p': function (d_date, n_value) { d_date.setDate(Number(n_value)); if (d_date.getDate() != n_value) d_date.setDate(0); return d_date }, 'g': function (d_date) { var n_date = d_date.getDate(); return (n_date < 10 ? '0' : '') + n_date; }},// Day of the month without leading zeros{'t': 'j', 'r': '0?[1-9]|[12][0-9]|3[01]', 'p': function (d_date, n_value) { d_date.setDate(Number(n_value)); if (d_date.getDate() != n_value) d_date.setDate(0); return d_date }, 'g': function (d_date) { var n_date = d_date.getDate(); return n_date; }},// A full textual representation of the day of the week{'t': 'l', 'r': A_TCALCONF.longwdays.join('|'), 'p': function (d_date, s_value) { return d_date }, 'g': function (d_date) { return A_TCALCONF.longwdays[d_date.getDay()]; }},// English ordinal suffix for the day of the month, 2 characters{'t': 'S', 'r': 'st|nd|rd|th', 'p': function (d_date, s_value) { return d_date }, 'g': function (d_date) { n_date = d_date.getDate(); if (n_date % 10 == 1 && n_date != 11) return 'st'; if (n_date % 10 == 2 && n_date != 12) return 'nd'; if (n_date % 10 == 3 && n_date != 13) return 'rd'; return 'th'; }} ]; function f_tcalGetHTML (d_date) { var e_input = f_tcalGetInputs(true);if (!e_input) return; var s_pfx = A_TCALCONF.cssprefix,s_format = A_TCALCONF.format; // today from config or client datevar d_today = f_tcalParseDate(A_TCALCONF.today, A_TCALCONF.format);if (!d_today)d_today = f_tcalResetTime(new Date()); // selected date from input or config or today var d_selected = f_tcalParseDate(e_input.value, s_format);if (!d_selected)d_selected = f_tcalParseDate(A_TCALCONF.selected, A_TCALCONF.format);if (!d_selected)d_selected = new Date(d_today); // show calendar for passed or selected dated_date = d_date ? f_tcalResetTime(d_date) : new Date(d_selected); var d_firstDay = new Date(d_date);d_firstDay.setDate(1);d_firstDay.setDate(1 - (7 + d_firstDay.getDay() - A_TCALCONF.weekstart) % 7); var a_class, s_html = '<table id="' + s_pfx + 'Controls"><tbody><tr>'+ (A_TCALCONF.yearscroll ? '<td id="' + s_pfx + 'PrevYear" ' + f_tcalRelDate(d_date, -1, 'y') + ' title="' + A_TCALCONF.prevyear + '"></td>' : '')+ '<td id="' + s_pfx + 'PrevMonth"' + f_tcalRelDate(d_date, -1) + ' title="' + A_TCALCONF.prevmonth + '"></td><th>'+ A_TCALCONF.months[d_date.getMonth()] + ' ' + d_date.getFullYear()+ '</th><td id="' + s_pfx + 'NextMonth"' + f_tcalRelDate(d_date, 1) + ' title="' + A_TCALCONF.nextmonth + '"></td>'+ (A_TCALCONF.yearscroll ? '<td id="' + s_pfx + 'NextYear"' + f_tcalRelDate(d_date, 1, 'y') + ' title="' + A_TCALCONF.nextyear + '"></td>' : '')+ '</tr></tbody></table><table id="' + s_pfx + 'Grid"><tbody><tr>'; // print weekdays titlesfor (var i = 0; i < 7; i++)s_html += '<th>' + A_TCALCONF.weekdays[(A_TCALCONF.weekstart + i) % 7] + '</th>';s_html += '</tr>' ; // print calendar tablevar n_date, n_month, d_current = new Date(d_firstDay);while (d_current.getMonth() == d_date.getMonth() ||d_current.getMonth() == d_firstDay.getMonth()) { s_html +='<tr>';for (var n_wday = 0; n_wday < 7; n_wday++) { a_class = [];n_date = d_current.getDate();n_month = d_current.getMonth(); if (d_current.getMonth() != d_date.getMonth())a_class[a_class.length] = s_pfx + 'OtherMonth';if (d_current.getDay() == 0 || d_current.getDay() == 6)a_class[a_class.length] = s_pfx + 'Weekend';if (d_current.valueOf() == d_today.valueOf())a_class[a_class.length] = s_pfx + 'Today';if (d_current.valueOf() == d_selected.valueOf())a_class[a_class.length] = s_pfx + 'Selected'; s_html += '<td' + f_tcalRelDate(d_current) + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>';d_current.setDate(++n_date);}s_html +='</tr>';}s_html +='</tbody></table>'; return s_html;} function f_tcalRelDate (d_date, d_diff, s_units) { var s_units = (s_units == 'y' ? 'FullYear' : 'Month');var d_result = new Date(d_date);if (d_diff) {d_result['set' + s_units](d_date['get' + s_units]() + d_diff);if (d_result.getDate() != d_date.getDate())d_result.setDate(0);}return ' onclick="f_tcalUpdate(' + d_result.valueOf() + (d_diff ? ',1' : '') + ')"';} function f_tcalResetTime (d_date) {d_date.setMilliseconds(0);d_date.setSeconds(0);d_date.setMinutes(0);d_date.setHours(12);return d_date;} // closes calendar and returns all inputs to default statefunction f_tcalCancel () { var s_pfx = A_TCALCONF.cssprefix;var e_cal = document.getElementById(s_pfx);if (e_cal)e_cal.style.visibility = '';var a_inputs = f_tcalGetInputs();for (var n = 0; n < a_inputs.length; n++)f_tcalRemoveClass(a_inputs[n], s_pfx + 'Active');} function f_tcalUpdate (n_date, b_keepOpen) { var e_input = f_tcalGetInputs(true);if (!e_input) return; d_date = new Date(n_date);var s_pfx = A_TCALCONF.cssprefix; if (b_keepOpen) {var e_cal = document.getElementById(s_pfx);if (!e_cal || e_cal.style.visibility != 'visible') return;e_cal.innerHTML = f_tcalGetHTML(d_date, e_input);}else {e_input.value = f_tcalGenerateDate(d_date, A_TCALCONF.format);f_tcalCancel();}} function f_tcalOnClick () { // see if already openedvar s_pfx = A_TCALCONF.cssprefix;var s_activeClass = s_pfx + 'Active';var b_close = f_tcalHasClass(this, s_activeClass); // close all clalendarsf_tcalCancel();if (b_close) return; // get position of inputf_tcalAddClass(this, s_activeClass); var n_left = f_getPosition (this, 'Left'),n_top = f_getPosition (this, 'Top') + this.offsetHeight; var e_cal = document.getElementById(s_pfx);if (!e_cal) {e_cal = document.createElement('div');e_cal.onselectstart = function () { return false };e_cal.id = s_pfx;document.getElementsByTagName("body").item(0).appendChild(e_cal);}e_cal.innerHTML = f_tcalGetHTML(null);e_cal.style.top = n_top + 'px';e_cal.style.left = (n_left + this.offsetWidth - e_cal.offsetWidth) + 'px';e_cal.style.visibility = 'visible';} function f_tcalParseDate (s_date, s_format) { if (!s_date) return; var s_char, s_regexp = '^', a_tokens = {}, a_options, n_token = 0;for (var n = 0; n < s_format.length; n++) {s_char = s_format.charAt(n);if (A_TCALTOKENS_IDX[s_char]) {a_tokens[s_char] = ++n_token;s_regexp += '(' + A_TCALTOKENS_IDX[s_char]['r'] + ')';}else if (s_char == ' ')s_regexp += '\\s';elses_regexp += (s_char.match(/[\w\d]/) ? '' : '\\') + s_char;}var r_date = new RegExp(s_regexp + '$');if (!s_date.match(r_date)) return; var s_val, d_date = f_tcalResetTime(new Date());d_date.setDate(1); for (n = 0; n < A_TCALTOKENS.length; n++) {s_char = A_TCALTOKENS[n]['t'];if (!a_tokens[s_char])continue;s_val = RegExp['$' + a_tokens[s_char]];d_date = A_TCALTOKENS[n]['p'](d_date, s_val);} return d_date;} function f_tcalGenerateDate (d_date, s_format) { var s_char, s_date = '';for (var n = 0; n < s_format.length; n++) {s_char = s_format.charAt(n);s_date += A_TCALTOKENS_IDX[s_char] ? A_TCALTOKENS_IDX[s_char]['g'](d_date) : s_char;}return s_date;} function f_tcalGetInputs (b_active) { var a_inputs = document.getElementsByTagName('input'),e_input, s_rel, a_result = []; for (n = 0; n < a_inputs.length; n++) { e_input = a_inputs[n];if (!e_input.type || e_input.type != 'text')continue; if (!f_tcalHasClass(e_input, 'tcal'))continue; if (b_active && f_tcalHasClass(e_input, A_TCALCONF.cssprefix + 'Active'))return e_input; a_result[a_result.length] = e_input;}return b_active ? null : a_result;} function f_tcalHasClass (e_elem, s_class) {var s_classes = e_elem.className;if (!s_classes)return false;var a_classes = s_classes.split(' ');for (var n = 0; n < a_classes.length; n++)if (a_classes[n] == s_class)return true;return false;} function f_tcalAddClass (e_elem, s_class) {if (f_tcalHasClass (e_elem, s_class))return; var s_classes = e_elem.className;e_elem.className = (s_classes ? s_classes + ' ' : '') + s_class;} function f_tcalRemoveClass (e_elem, s_class) {var s_classes = e_elem.className;if (!s_classes || s_classes.indexOf(s_class) == -1)return false; var a_classes = s_classes.split(' '),a_newClasses = []; for (var n = 0; n < a_classes.length; n++) {if (a_classes[n] == s_class)continue;a_newClasses[a_newClasses.length] = a_classes[n];}e_elem.className = a_newClasses.join(' ');return true;} function f_getPosition (e_elemRef, s_coord) {var n_pos = 0, n_offset,e_elem = e_elemRef; while (e_elem) {n_offset = e_elem["offset" + s_coord];n_pos += n_offset;e_elem = e_elem.offsetParent;} e_elem = e_elemRef;while (e_elem != document.body) {n_offset = e_elem["scroll" + s_coord];if (n_offset && e_elem.style.overflow == 'scroll')n_pos -= n_offset;e_elem = e_elem.parentNode;}return n_pos;} function f_tcalInit () { if (!document.getElementsByTagName)return; var e_input, a_inputs = f_tcalGetInputs();for (var n = 0; n < a_inputs.length; n++) {e_input = a_inputs[n];e_input.onclick = f_tcalOnClick;f_tcalAddClass(e_input, A_TCALCONF.cssprefix + 'Input');} window.A_TCALTOKENS_IDX = {};for (n = 0; n < A_TCALTOKENS.length; n++)A_TCALTOKENS_IDX[A_TCALTOKENS[n]['t']] = A_TCALTOKENS[n];} function f_tcalAddOnload (f_func) {if (document.addEventListener) {window.addEventListener('load', f_func, false);}else if (window.attachEvent) {window.attachEvent('onload', f_func);}else {var f_onLoad = window.onload;if (typeof window.onload != 'function') {window.onload = f_func;}else {window.onload = function() {f_onLoad();f_func();}}}} f_tcalAddOnload (f_tcalInit);
×
×
  • Create New...