Jump to content

w3schoon

Members
  • Posts

    50
  • Joined

  • Last visited

Everything posted by w3schoon

  1. Nice be with you everyone! Can you give some tutorials about Validates Form using PHP with Ajax & JQuery? I red that it is the best practice...
  2. Nice be with you everyone! My problem is: Every time I refresh my showDatabaseCatalog.php there is always insertion of blank data in MySQL database? Can anyone help me how to stop this undesirable insertion of blank data in MySQL database when refresh? Thank you.
  3. Thank you very much! I really want to learned how to debug javascript using console.log, but my problem is where I should start?Any link of good console.log Introduction?
  4. @ dsonesuk: Thank's for editing, I really appreciated your effort and I learned a lot of things I have another question my friends, Is it good practice to place jQuery selectors in a variables for optimisation? Here's my code: $(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; } }); });
  5. @ Callumacrae: Wow! Thank you very much! I followed your advice and it works! I set my jQuery click event handler outside jQuery hover & mouseenter event handlers and it works! Here's my code: $(document).ready(function(){ $("#weight").hover(function(){ $("#show").css("display", "block"); }, function(){ $("#show").css("display", "none").mouseenter(function(){ $(this).css("display", "block").mouseleave(function(){ $(this).css("display", "none"); }); }); }); $("#show").click(function(){ $(this).css("display", "none"); var a=prompt("Convert pouds to kilograms:",""); b=a * 0.45359237; // 1 lb = 0.45359237 kg b=b.toFixed(2); if (!isNaN(a)) { // If not illegal number if (a != 0) { // If not empty value alert(a + " pouds = " + b + " kilograms"); $("#weight").val(; } else alert("Error: Empty value!"); // If empty value } else alert("Error: Illegal number!"); // If illegal numer }); });
  6. Wow! That is amazing, I usually use alert() statements for debugging and I didn't know that console.log is more useful than alert() statements! May I know where I can find "browser's Javascript console" (if my browser is Google Chrome)? Thanks a lot!
  7. Oh.. I see.. Thanks but is there anything I can do besides ?Like methods or functions that will stop alert/prompt form continuously appearing?
  8. Nice be with you everyone! My problem is: Every time I click "#show" my prompt is continuously appearing though I click OK, cancel or close? Here is my code: <script type="text/javascript" src="javascripts/jquery-1.9.1.min.js"></script> <script> $(document).ready(function(){ $("#weight").hover(function(){ $("#show").css("display", "block"); }, function(){ $("#show").css("display", "none"); $("#show").mouseenter(function(){ $(this).data("mouse", "enter"); if ($(this).data("mouse") == "enter"){ $(this).css("display", "block").click(function(){ var converted = prompt ("Convert poud to kilograms:","")answer = converted * 0.45359237; // 1 lb = 0.45359237 kganswer = answer.toFixed(2); if (!isNaN(converted)) { // If not illegal number if (converted != 0) { // If not empty valuealert(converted + " poud = " + answer + " kilograms");$("#weight").val(answer); } else alert("Error: Empty value!"); // If empty value } else alert("Error: Illegal number!"); // If illegal number });}});});}); </script> Take a look my attached picture. Thank you.
  9. Nice be with you everyone! My question is: What is the usage of console.log in jQuery? Thank you.
  10. Thanks a lot guys! I learned many things and I will start studying Regular Expressions!
  11. Sorry for my bad code (above), unfortunately I missed many things. 1st. Through searching I found out that variables with value can be use as agruments, http://www.w3schools.com/js/js_functions.asp 2nd. I noticed that "this" in the var A=$(this).text() has no value inside function li() 3rd. Inorder to have value, "this" should be inside of $("#ul1 li ul a").on("click",function(){ $(this).text(); } 4th. Finally it works! After I passed "this" argument in the li(this, #cut1" "#cut2" "Medical positions"); here is my code and it works! <script type="text/javascript" src="javascripts/jquery-1.9.1.min.js"></script> <script> function li(X, D, C, D){ var A=$(X).text();$(.text(A.substr(0,19)); $("#job").removeAttr("name value"); $("#position").attr({"name":"jobApplied", "value":A }); $(.css({"color":"#000", "background":"#fff" }); $(C).css({"color":"#a9a9a9", "background":"#d9d9d9"}).text(D); $("#job").css({"background":"#d9d9d9" }); } $(document).ready(function(){$("#ul1 li ul a").on("click",function(){ li(this, "#cut1", "#cut2", "Medical positions"); });}); $(document).ready(function(){$("#ul2 li ul a").on("click",function(){ li(this, "#cut2", "#cut1", "Technical positions"); });}); </script>
  12. @callumacrae: Thanks a lot for the info. But why did you said, ? Can you give me very good link about regex?
  13. Nice be with you everyone! My problem is how to call javascript function inside jquery? <script type="text/javascript" src="javascripts/jquery-1.9.1.min.js"></script> <script> function li(){ var A=$(this).text();$(.text(A.substr(0,19)); $("#job").removeAttr("name value"); $("#position").attr({"name":"jobApplied", "value":A }); $(.css({"color":"#000", "background":"#fff" }); $(C).css({"color":"#a9a9a9", "background":"#d9d9d9"}).text(D); $("#job").css({"background":"#d9d9d9" }); } $(document).ready(function(){$("#ul1 li ul a").on("click",function(){ var B="#cut1", C="#cut2", D="Medical positions"; /* I want to call function li() here but it is not working */ });}); $(document).ready(function(){$("#ul2 li ul a").on("click",function(){ var B="#cut2", C="#cut1", D="Technical positions"; /* I want to call function li() here but it is not working */ });}); </script> Thank you.
  14. Nice to be with you everyone! I want to remove spaces using JavaScript and I found this in the web, var a=" W 3 S c h o o l s ";a.replace(/\s/g, ''); output: W3schools I learned that, replace(); - method searches a string for a specified value... http://www.w3schools.com/jsref/jsref_replace.asp \s - Find a whitespace character... http://www.w3schools.com/jsref/jsref_obj_regexp.asp /g - Perform a global match... http://www.w3schools.com/jsref/jsref_obj_regexp.asp '' - Empty string My question is, what is the purpose of "/" before \s? Thank you.
  15. Guys, I used all your suggestions, what can you say about this program above? I tested it and run properly. Thank you for your advices.
  16. <!DOCTYPE html><html><head><title>Reset input date</title><script type="text/javascript">// Function to add event listener to id2function load() {var a=document.getElementById("id2");a.addEventListener("click", resetDate, false);}// Function to reset input datefunction resetDate() {var a=new Date();a.setFullYear(0,0,0);var b=document.getElementById("id1");b.value=a;}document.addEventListener("DOMContentLoaded", load, false);</script></head><body><input id="id1" type="date" name="date"><button id="id2">Reset Date</button></body></html>
  17. Did you mean like this?________________________________________________________________________________________________________ function load() { var a = document.getElementsByName("name")[0]; a.addEventListener("click", function(){ reset() }, false); }________________________________________________________________________________________________________ @callumacrae: Am I right?
  18. w3schoon

    form validation

    Can we see your code? So we can better understand...
  19. Finally I made it (reset input date)!_________________________________________________________________________________________________________ // Here is my code: <script type="JavaScript"> function reset() { // Creat date datatype variable and set it to null value var a=new Date();a.setFullYear(0,0,0); // Get input date element and insert a value with that variable var b=document.getElementsByName("name")[0];b.value=a; } <script> <input type="date" name="date"> <button onclick="reset()">Reset Date</button>_________________________________________________________________________________________________________ @dsonesuk: Thank you for http://w3schools.com...ef_obj_date.asp @niche: Thank you I found out that innerHTML is only for changing text inside of an element.
  20. Nice be with you everyone! Problem: Is there a function that will reset input date?_________________________________________________________________________________________________________ // Here's my code: <script type="JavaScript"> function reset() { // Is there a function that will reset input date?} <script> <input type="date" name="date"> <button onclick="reset()">Reset Date</button>_________________________________________________________________________________________________________ Thank you.
  21. Nice to be with you everyone! Problem: Is it good practice to used class and id in a single element? Example: <p id="a" class="b"> Correct me <p> Thank you.
  22. Thank you, for letting me know settype function for converting variables into different data type
  23. Nice to be with you everyone! I have a problem: How to convert numbers to strings using PHP. Try this, $number=11; to convert in string? Thank you.
  24. If you are PHP developer it is best practice to use PHP framework like cakephp, codeigniter, symphony, zend framework etc. Frameworks will help you a lot not just only organizing your files and folders but also to utilize and secure your codes. Try this: http://www.phpandstuff.com/articles/top-10-reasons-why-you-should-use-a-php-framework
×
×
  • Create New...