Jump to content

w3schoon

Members
  • Posts

    50
  • Joined

  • Last visited

Everything posted by w3schoon

  1. Nice be with you everyone! What is the main difference between If else and Shorthand If? Example: If ($gender == 'male') echo 'Hi Sir!'; else echo 'Hi Mam!'; and ($gender == 'male') ? echo 'Hi Sir!' : echo 'Hi Mam!'; Thank you in advance!
  2. Nice be with you everyone! I'm a beginner in CodeIgniter framework and I'm really interested to explore its classes, methods, properties, etc... May I know what is the usage of CI_Controller, load, helper, library, form,_validation, run & view ? I found these here... <?phpclass Form extends CI_Controller {function index(){ $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); if ($this->form_validation->run() == FALSE) { $this->load->view('myform'); } else { $this->load->view('formsuccess'); }}}?> Thanks in advance!
  3. Nice be with you everyone! May I now what's the purpose of <html lang="en"> ? Thank you in advance!
  4. Thanks a lot guys. Good explanations, I got what you mean. Now I know the usage data: in Ajax...
  5. What do you mean JSG? Till now I don't understand what the usage of ajax=1 when it pass to the path i.e. url
  6. Nice be with you everyone! Question:1. How to select multiple id's or elements with hover?I want to simplify this, // CSS or JQuery Selector#id:hover, #name:hover, #age:hover{ } to this one, (#id, #name, #age):hover{ // I know this is wrong selector but is there any way to select like this one for optimisation?} Thank you in advance!
  7. @thescientist: Wow you're right, instead of includes/delete.php I misspelled the path to javascripts/delete.php. Thank you for the correction, now my $.ajax() is running successfully but the problem is: Why the selected database was not deleted after $.ajax() ran successfully? @justsomeguy: Oh I see, in your link. I learned that my client was able to communicate with the server, but the problem is the server could not find what was requested. Can you look at my PHP request? Here's my code: <?php // This is includes/delete.php include "mysqlCon.php"; if (isset($_GET['delete'])){ $query="DELETE FROM applicants WHERE id=".(int)$_GET['delete']; mysql_query($query); } mysql_close($conServ); ?> Thank you.
  8. Nice be with you everyone! Problem:Every time I click delete (database) button it always trigger 404: and respond "Could not contact server". Questions:1. What is Error 404?2. And how to fix it to run Ajax successfully? Here's my code: var parent=$(this).closest("tr"); $.ajax({ type:'get', url:'javascripts/delete.php', data:'ajax=1&delete='+$(this).attr('id'), statusCode: { 404: function() { $("#alert").html('Could not contact server.'); }, 500: function() { $("#alert").html('A server-side error has occurred.'); } }, error: function() { $("#alert").html('A problem has occurred.'); }, success:function(){ $("#alert").html('Successful!'); parent.fadeOut(300, function(){ parent.remove(); }); } }); Thank you!
  9. Thank you very much, now I understand. How about ajax=2 or 3 or 4 or n... ?
  10. Nice be with you everyone! I'm planing to use JQuery $.ajax() method to delete 1 row of my database. While searching I found this on the web... $.ajax({ type: 'get', url: '/examples/delete.php', data: 'ajax=1&delete=' + $(this).attr('id'), success: function() { parent.fadeOut(300,function() { parent.remove(); }); } }); I have questions: 1. What is the difference of post & get in the type: ?2. What is the usage of 'ajax=1&delete=' in the data: ?3. If there is success: how about if not success, I mean error handler? Thank you.
  11. Thank you for the reply! Finally by experimentation I solved the problem on how to put JQuery inside JavaScript Protoype What am I trying to do is to make a Javasscript prototype that maximums number of characters allowed in the <input> element using maxlength. To simplify my code I decided to use attr() method, unfortunately It didn't work, but blessedly by trial and error I found out that my problem is simple. Use "String.prototype" if your constructor is for String e.g. length(), replace(), etc. Use "Object.prototype" if your constructor is for Object e.g. attr() etc. Here's my code and it's working! Try it yourself >> <!DOCTYPE html> <html> <head> <title>Applicant Tracking Database System</title> <script type="text/javascript" src="javascripts/jquery-1.9.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ Object.prototype.maxlength=function(a){ this.attr("maxlength",a); }; $("#name").maxlength(10); }); </script> </head> <body> <p>Name: <input id="name" type="text" name="name"></p> </body></html> Thank you!
  12. Nice be with you everyone! I found out that input required attribute requires "that an input field must be filled out before submitting the form." like this... <form action="demo_form.asp">Username: <input type="text" name="usrname" required><input type="submit"></form> My question is: Is it possible also to use input required attribute in select? like this... <select name="gender" required><option value="" selected="selected">Choose...</option><option value="male">Male</option><option value="female">Female</option></select> I want to validate gender field if it has already value (male or female)otherwise will not submit like what input required attribute can do Thank you.
  13. Nice be with you everyone! My problem is: How to put JQuery inside JavaScript Protoype? Here's my code: <script type="text/javascript"> $(document).ready(function(){ String.prototype.maxlength=function(a){ return this.attr("maxlength", a); } $("#name").maxlength(32); }); </script> And this... <body> <p>Name: <input id="name" type="text" name="name" value=""></p> <input type="submit" value="submit"> </body> My reason of using this prototype is to simplify my codes. Thank you.
  14. Nice be with you everyone! In MySQL: Is there data type that accepts non-alphanumeric?
  15. Nice be with you everyone! After I've learned setting JQuery selectors in a variables for optimisation.Example: $(document).ready(function(){ $("form").submit(function(){ var a=$("#position"); var b=$("#job"); var c=$("input#religion"); var d="Others"; if (a.val() == "" && b.val() == d ){ b.val("").focus(); return false; } if (c.val() == d){ c.val("").focus(); return false; } }); }); My related question is: Can I set JQuery methods in a variables for optimisation?Example: $(document).ready(function(){ var a=attr("maxlength", 32); $("#specialty").a; }); Thank you.
  16. Nice be with you everyone! While reading http://www.w3schools...s_obj_array.asp I've noticed two confusing arrays... 2: Condensed: var myCars=new Array("Saab","Volvo","BMW"); 3: Literal: var myCars=["Saab","Volvo","BMW"]; My question is: What is the difference between Literal arrays & Condensed Arrays? & which of them is better to use? Thank you.
  17. Thanks for the thread http://w3schools.inv...howtopic=12509. Now I know where should I start. While reading your thread, I see this (below) & tried to used in my web page & it works! <?phpif (isset($_POST['submit_button'])){ //the form was submitted}?> My next problem is how to follow your next advice... My question is: Where do PHP store $_SESSION variables? If Cookies are stored at Google Chrome's toolbar > Settings > Advance Settings > Privacy > Content Settings > All cookies and site dataWhere are sessions data?
  18. Thank you for the reply. After reading your replies, I came up with two questions: #1. What do you mean, ?Isn't it the PHP & not the Ajax that will do the job of submitting and processing the form after the data has been validated? #2. What do you mean, ?You mean I should only use pure Javascript for client-side validation & not with the JQuery or any other Javascript libraries? Sorry If I have too many questions, I just really want to learned from the experts
  19. Thank you so much for sharing your programming skills! I really enjoy learning jQuery in this forum
  20. I'm start confusing now for what you had said, I red that Ajax can do... Can you tell me why ? The reason why I became interested to use Ajax for validation of form is because of this http://jqueryfordesigners.com/demo/ajax-validation.php (do not click the link but copy & paste it in the URL bar)
  21. Yes, There is a data before submitting the form. My problem is this, $name=$_POST['name']; $price=$_POST['price'];$inserted="INSERT INTO students (name, price) VALUES ('$name', '$price')";mysql_query($inserted); Every time I refresh showDatabaseCatalog.php with these codes, it always duplicating the last data inserted from the form or if I direct open showDatabaseCatalog.php without submitting, it insert blank data in the MySQL database when refresh?
  22. Nice be with you everyone! I'm just came here for one reason,..
×
×
  • Create New...