Jump to content

w3schoon

Members
  • Posts

    50
  • Joined

  • Last visited

Posts 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! 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!

  4. @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? :sorry: @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.

  5. 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!

  6. 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.

  7. 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!

  8. 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.

  9. 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.

  10. 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.

  11. 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...

    If you want to stop it from inserting duplicate data, then your options are to either store the data you just inserted in the session and, if the form was submitted you should compare the submitted data with the last data from the session and don't insert if they are the same. Or, after you insert you can send a location header to redirect the user back to the same page which will clear the post data if they refresh. -justsomeguy
    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?
  12. Thank you for the reply. After reading your replies, I came up with two questions: #1. What do you mean,

    If you're using AJAX to submit and process the form after the data has been validated then, yes, you don't need to worry about pure client-side validation. -Ingolme
    ?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,
    Best practise involves pure Javascript on the client-side -Ingolme
    ?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 :Pleased:
  13. I'm start confusing now for what you had said, I red that Ajax can do...

    1. Live username checking2. Password confirmation and strength3. Checking if an email address is already registered4. URL validation, i.e. Basecamp's site address checks if the URL is available (pretty much the same as username validation) from: http://jqueryfordesi...validate-forms/
    Can you tell me why
    AJAX would just slow down the process. -Ingolme
    ? 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)
  14. 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?

×
×
  • Create New...