Jump to content

Search the Community

Showing results for tags 'js'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 100 results

  1. In a js tutorial of w3schools it is mentioned that calling a js file is done either in the head or body; if in the body, it is preferable to be at the bottom to avoid slowing down page loading should the js loading is slow. Since the browser reads the page from top to bottom, it will hit the head first. Does that mean calling a js file at the bottom of the body is better than calling it in the head?
  2. Dear all: I am intending to use jQuery for an FAQ collapsible/uncollapsible text. Because my FAQ will contain essential information, I am keen to have it visible to everybody. Is there any limitation in relation to browser support of jQuery that I should be aware of?
  3. Dear all: I know it is not usually normal to make double links of any file, however, since jQuery library can be linked to the page via the internet or locally, can we do both linking to achieve guaranteed loading if one fails and to make sure that getting the first link of the two would mean a faster loading? Is there any harm of doing so?
  4. Hey all i have following problem: I have a drag and drop editor which allow me to edit a URL, or allow me to edit a image trough a pop up screen. Now i want to change this so i edit the code of a image with URL (click able image). As you can see in the code below, everything works fine. Except it only shows 1 attribute So when i remove the <a></a> tags it shows the image url When i remove the <img></img tags it show the website url when i enable both only 1 shows up (website url) Anyone with a bit more javascript knowledge knows whats wrong ? Javascript: //edit link & image if(big_parent.attr("data-type")=='imagelink'){ $("#sim-edit-imagelink .imagelink").val(big_parent.children('img').attr("src")); $("#sim-edit-imagelink .imageurl").val(big_parent.children('a').attr("href")); $("#sim-edit-imagelink").fadeIn(500); $("#sim-edit-imagelink .sim-edit-box").slideDown(500); $("#sim-edit-imagelink .sim-edit-box-buttons-save").click(function() { $(this).parent().parent().parent().fadeOut(500); $(this).parent().parent().slideUp(500); big_parent.children('img').attr("src", $("#sim-edit-imagelink .imagelink").val()); big_parent.children('a').attr("href", $("#sim-edit-imagelink .imageurl").val()); }); html code <div class="sim-row-edit" data-type="imagelink" style="text-align:left"> <a href="http://google.be" target="_blank"> <img src="http://fietsendezwaluw.be/news/builder/img/layout1/img4.jpg" alt="" width="195" height="155" /> </a> </div> html code popup screen <div class="sim-edit" id="sim-edit-imagelink"><div class="sim-edit-box" style="height:330px;" ><div class="sim-edit-box-title">Edit image and url</div><div class="sim-edit-box-content"><div class="sim-edit-box-content-text">URL image:<span>(please use http://)</span></div><div class="sim-edit-box-content-field"><input type="text" class="sim-edit-box-content-field-input imagelink"/></div><div class="sim-edit-box-content-text">URL link:<span>(please use http://)</span></div><div class="sim-edit-box-content-field"><input type="text" class="sim-edit-box-content-field-input imageurl"/></div></div><div class="sim-edit-box-buttons"><div class="sim-edit-box-buttons-save">Save</div><div class="sim-edit-box-buttons-cancel">Cancel</div></div></div></div> Click here for the live example as you can notice when you press on a image it only show http://google.be and it doesn't show the image url.
  5. Dear all: May I kindly request a help in providing a nice code for collapsing and expanding a block of text, e.g., blah blah blah read more... then at the bottom of the expanded page a way to collapse the block to original status. I searched the web and found some code in js, a language I don't know. Can that be achieved in PHP or html?
  6. Hey all, I have the code which display the result in a box, however i want to alter the code so it stores the result in a php session instead of displaying directly. //Preview$("#newsletter-builder-sidebar-buttons-cbutton").click(function(){ $("#sim-edit-export").fadeIn(500); $("#sim-edit-export .sim-edit-box").slideDown(500); $("#newsletter-preloaded-export").html($("#newsletter-builder-area-center-frame-content").html()); $("#newsletter-preloaded-export .sim-row-delete").remove(); $("#newsletter-preloaded-export .sim-row").removeClass("ui-draggable"); $("#newsletter-preloaded-export .sim-row-edit").removeAttr("data-type"); $("#newsletter-preloaded-export .sim-row-edit").removeClass("sim-row-edit"); preload_export_html = $("#newsletter-preloaded-export").html(); $.ajax({ url: "css/newsletter.css" }).done(function(data) { export_content = '<style>'+data+'</style><link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic" rel="stylesheet" type="text/css"><link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"><div id="sim-wrapper"><div id="sim-wrapper-newsletter">'+preload_export_html+'</div></div>'; $("#sim-edit-export .text").val(export_content); }); $("#newsletter-preloaded-export").html(' '); }); Thanks in advance! funstad
  7. First of all, sorry if this is an inappropriate place to post this thread but I don't really know a better place to post it. This isn't any full time job, more of a partnership. I'm sure for a skilled programmer this would be rather easy.. But I am not one, which is why I'm looking for help.I want someone who can program games, such as a coin flipping game, slot machine game and games like blackjack (although, I have a coin flipping and slot machine game coded, just not by me) and integrate them with the Steam/CS:GO API, allowing users to log in, send CS:GO skins/knives (which can be very valuable) to a bot and then play these games for the chance of winning a lot more skins/knives.If you aren't fully accustomed to the Steam/CS:GO API then there are official Steam API guides. I have a couple more things I would like added which I will discuss if you contact me.Email: csgoroulettebusiness@gmail.comPay: All profits 50/50, a payment at the end could be arranged but I am spending a lot of money on other things important for the website (advertising although it's rather low-key, domains since I'm thinking about switching to a different one, creating a stockpile of skins/knives so that I can actually have the games functioning and not have people spending skins on games with no chance of winning anything and there's more I need to pay for but I hope you understand I'm not just BSing or something). Some of the more popular websites out there already make a lot of money from doing this, so if we improve upon what they've done, add more features, games etc and add a better monetary system, then the pay should be quite a lot, that is if all games/elements are implemented.Why bother helping?: First of all, the domain is already paid for, but like I said, I might buy a new off someone who's selling it. Quite a lot of the website is finished but there's still quite a bit more to do. You get to sleep soundly tonight knowing that you've helped a fellow programmer create something he loves. And, well, all you have to do is do some programming and sit back and watch the money roll in. Might sound too good to be true and although there's quite a bit of programming involved, it really is as simple as that. The websites out there are either basic, scams or just very poor and I hope to change that. I have plenty of new and fresh ideas which would entice a lot of CS:GO gamers and possibly even streamers to my website. I also have a different way for the site to earn money which greatly benefits both the creators and the users.Thanks for reading,Joe
  8. hi , i try to write a function that provide to change the image when i click on it: <body> <script> function hide(){ if (document.getElementById("image").src == "arrowup.png"){ document.getElementById("image").src = "arrowdown.png"; } else { document.getElementById("image").src = "arrowup.png"; } } </script> <img id="image" onclick="hide()" src="arrowdown.png" width="30" height="30"/> </body> but it doesnt work , what is the problem, please????
  9. hi! i'm new to HTML but i can programme with c,j2EE and JS , i want to know if there is a way to run my code in an html page, (i mean doing an application inside the HTML page);
  10. So I am learning JavaScript, and I come across this (which is one of the first things I learned about JS from your website, thank you). The first "method", if you call it that, which you show is the .innerHTML method to change the interior of an HTML element, given a named id. I have since learned other methods to be used with it, such as .value and .style. But I have never seen a comprehensive list of all the methods that can be used with this command. Either I'm not looking in the right place (which is entirely possible), or it's just not there. Since this is supposed to be a comprehensive website for all things related to web development, I think this would be a great addition to an already great website.
  11. Hi everybody! I just made this slider in an object oriented fashion. I would like to know how I can improve the script. Thank you! var Slideshow = function(element) { var totalWidth = 0; this.slider_wrap = element.find('.slider_wrap'); this.slider = element.find('.slider'); this.slide = element.find('.slide'); this.first_slide = element.find('.slide:first'); this.slider_controls_prev = element.find('.slider_controls_prev'); this.slider_controls_next = element.find('.slider_controls_next'); this.all_slides = this.slide.each(function(){ totalWidth = totalWidth + jQuery(this).outerWidth(true); }); this.maxScrollPosition = totalWidth - this.slider_wrap.outerWidth(); this.toSliderItem = function(jQuerytargetItem){ if(jQuerytargetItem.length){ this.newPosition = jQuerytargetItem.position().left; if(this.newPosition <= this.maxScrollPosition){ jQuerytargetItem.addClass('active'); jQuerytargetItem.siblings().removeClass('active'); this.slider.animate({ left : - this.newPosition }); } else { this.slider.animate({ left : - this.maxScrollPosition }); }; }; }; this.slider.width(totalWidth); this.first_slide.addClass('active'); this.buttons(); } Slideshow.prototype.buttons = function() { var that = this; this.slider_controls_prev.click(function() { var jQuerytargetItem = that.slider.find('.active').prev(); that.toSliderItem(jQuerytargetItem); }); this.slider_controls_next.click(function() { var jQuerytargetItem = that.slider.find('.active').next(); that.toSliderItem(jQuerytargetItem); });}var speakers = new Slideshow(jQuery('.slider-1'));}); The HTML: <div class="slider_wrap"> <div class="slider clearfix"> <div class="slide">Slide Content</div> </div> <div class="slider_controls clearfix"> <div href="#" class="slider_controls_prev"> ◄ </div> <div href="#" class="slider_controls_next"> ► </div> </div></div>
  12. I used a .js to avoid landscape view from mobile device. I edited a white full-screen image saying "this site is not thought to be viewed in landscape mode, please turn your device" to be shown each time I rotate my device from portrait to landscape. It works except when I load a page and I'm already in landscape mode. Any idea on how to fix it? Thanks <script>(function() {'use strict';var isMobile = {Android: function() {return navigator.userAgent.match(/Android/i);},BlackBerry: function() {return navigator.userAgent.match(/BlackBerry/i);},iOS: function() {return navigator.userAgent.match(/iPhone|iPad|iPod/i);},Opera: function() {return navigator.userAgent.match(/Opera Mini/i);},Windows: function() {return navigator.userAgent.match(/IEMobile/i);},any: function() {return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());}};if (isMobile.any()) {doOnOrientationChange();window.addEventListener('resize', doOnOrientationChange, 'false');}function doOnOrientationChange() {var a = document.getElementById('alert');var b = document.body;var w = b.offsetWidth;var h = b.offsetHeight;(w / h > 1) ? (a.className = 'show', b.className = 'full-body') : (a.className = 'hide', b.className = '');}})();</script> Update : I tried adding window.orientation to the script but something is wrong if (orientation === "landscape-primary") {doOnOrientationChange();window.addEventListener('resize',doOnOrientationChange,'false');}window.onload(doOnOrientationChange());
  13. I could use some help with the following problem: I have a contact formwith validation and it works fine. But there are 2 things that I would like to change: 1. The error messages are displayed in an errorlist at the top of the page. I would like the error message to be displayed in the formfield ( I tried that with placeholder, but that didn't work out) or other wise under, on top or at the and of each form field. 2. I would like the border-color to change to green when it is correctly fild. What is the best way to do that, with Jquery or a separate 'class' and css. (If I am right informed validation should be in PHP and not jQuery.) All my afforts to change the layout just resulted in a different error and nothing else. Could some one tell how, or where I can find how to change, the script so to achieve the different layout. Unnecessary to say that this is alle quit new for me. Thanx in advance Below you find the code of the contact form: <?php$aErrors = array();if ('POST' == $_SERVER['REQUEST_METHOD']) { if ( !isset($_POST['name']) or !preg_match( '~^[w ]{3,}$~', $_POST['name'] ) ) { $aErrors['name'] = 'Please fill in your name'; } if ( !isset($_POST['email']) or !preg_match( '~^[a-z0-9][a-z0-9_.-]*@([a-z0-9]+.)*[a-z0-9][a-z0-9-]+.([a-z]{2,6})$~i', $_POST['email'] ) ) { $aErrors['email'] = 'Please fill in your e-mail address'; } if ( !isset($_POST['address1']) or !preg_match( '~^[wd ]{5,}$~', $_POST['address1'] ) ) { $aErrors['address1'] = 'Please fill in your adress'; } if ( !isset($_POST['address2']) or !preg_match( '~^([wd ]{5,})?$~', $_POST['address2'] ) ) { $aErrors['address2'] = 'Please fill in your adress'; } if ( !isset($_POST['towncity']) or !preg_match( '~^[wd' ]*$~', $_POST['towncity'] ) ) { $aErrors['towncity'] = 'Please fill in your town/city'; } if ( !isset($_POST['postcode']) or !preg_match( '~^d{4} ?[a-zA-Z]{2}$~', $_POST['postcode'] ) ) { $aErrors['postcode'] = 'Please fill in your postal code'; } if ( count($aErrors) == 0 ) { header('Location: http://'); exit(); }}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Forms</title> <style type="text/css"> .errorlist, .error input{ border: 1px solid #f00; background: #fdd; } form.cmxform fieldset { margin-bottom: 10px; } form.cmxform legend { padding: 0 2px; font-weight: bold; } form.cmxform label { display: inline-block; line-height: 1.8; vertical-align: top; } form.cmxform fieldset ol { margin: 0; padding: 0; } form.cmxform fieldset li { list-style: none; padding: 5px; margin: 0; } form.cmxform em { font-weight: bold; font-style: normal; color: #f00; } form.cmxform label { width: 120px; /* Width of labels */ } </style> </head> <body> <form action="contact.php" method="post" class="cmxform"> <?php if ( isset($aErrors) and count($aErrors) > 0 ) { print '<ul class="errorlist">'; foreach ( $aErrors as $error ) { print '<li>' . $error . '</li>'; } print '</ul>'; } ?> <p>Please complete the form below. Mandatory fields marked <em>*</em></p> <fieldset> <legend>Delivery Details</legend> <ol> <?php echo isset($aErrors['name']) ? '<li class="error">' : '<li>' ?> <label for="name">Name<em>*</em></label> <input id="name" name="name" value="<?php echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '' ?>" /> </li> <?php echo isset($aErrors['email']) ? '<li class="error">' : '<li>' ?> <label for="email">E-mail<em>*</em></label> <input id="email" name="email" value="<?php echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '' ?>" /> </li> <?php echo isset($aErrors['address1']) ? '<li class="error">' : '<li>' ?> <label for="address1">Address<em>*</em></label> <input id="address1" name="address1" value="<?php echo isset($_POST['address1']) ? htmlspecialchars($_POST['address1']) : '' ?>" /> </li> <?php echo isset($aErrors['address2']) ? '<li class="error">' : '<li>' ?> <label for="address2">Address 2</label> <input id="address2" name="address2" value="<?php echo isset($_POST['address2']) ? htmlspecialchars($_POST['address2']) : '' ?>" /> </li> <?php echo isset($aErrors['towncity']) ? '<li class="error">' : '<li>' ?> <label for="towncity">Town/City</label> <input id="towncity" name="towncity" value="<?php echo isset($_POST['towncity']) ? htmlspecialchars($_POST['towncity']) : '' ?>" /> </li> <?php echo isset($aErrors['postcode']) ? '<li class="error">' : '<li>' ?> <label for="postcode">Postal Code<em>*</em></label> <input id="postcode" name="postcode" value="<?php echo isset($_POST['postcode']) ? htmlspecialchars($_POST['postcode']) : '' ?>" /> </li> </ol> <input type="submit" value="Verstuur" /> </fieldset> </form> </body></html>
  14. Ok, Hi everyone. I found this awesome and simplistic shopping cart on codepen.com BUT I do not know how to make it work .... :(TO begin with here is the link for it: http://codepen.io/bartveneman/details/KHxLGI am using Dreamweaver to make my website. So I copied it all, made sure that the links between my html, css and js are working fine and it still does not work. My problem with it is as follows: I did a copy+paste on it cannot shows me the cart without any items. I do not know how to add items without ruining the JS which will calculate things like total price, subtotal, etc. Things that I tried [ if you know exactly what I need to do don't bother reading what I tried, I am a beginner anyways ] I tried replacing inside the HTML the places where it says things like "src="{{=img}}" I would replace it the source with an actual source path for an image which works but shows nothing at all. I tried then also here in the HTMl file to simply take the tag off. As you see the html is based on one top part which is a big tag then is has the footer. The items are inside the tag at the top, BUT the tag is enclosed within some script tag so I removed the script and it shows one item ok-ish. The problem with this is that it would function with the script. For example it shows the item now but I cant add it to cart anything. Lastly, I looked inside the JS file and I found the section with the app variable which seems to have the details for the items included in the example. I changed those but nothing shows... So I tried some basic stuff. If anybody can help me with this by the end of the weekend it would be great !
  15. Hi guys, I need to work with "m³". The function in my script gets a value from a selection. I have 10 seletion options. It works fine with 9 of them, just the "m³" doesnt work. I read something about unicode, but couldn´t find the right one (if it exist für ^3). I also had a look at the w3 js pages (number, math), but that didn´t help too. if (abc == "m³") { var variable = "m³"; document.getElementById('show').innerHTML = variable;} Thanks for your hints, Chrex
  16. Hi guys, I use a very big form and my variables will be saved in a session. In most cases I´m fine with PHP. Until now I just use JS to hide and show some options. My idea is to give the user a selection (somewhere in my form). As soon as the user clicks on one of the selection options, the value of the variable shall appear as text below the selection options (not just in the selection options). 1. Idea - import the php-variables in my JS and work with it <script type="text/javascript">var test ="<?php echo $test ?>";</script> --> didnt work. I could work with the variable, but I dont get a "fresh" variable from the session, because I would have to push the form button first. 2. Idea - create a JS variable in the selection options <selection id="test"><option value=test1">Test1</option><option value=test2">Test2</option>...</selection> --> didnt work. Do you have any ideas what I should look for or what I have to do? Thanks and cheers, Chrex
  17. Hi All, When we create a object and invoke a method on it. 1. Instance will be searched and then the prototype and so on till the Object prototype; when will the Global object be searched ? also what is the role of activation Object ? My understanding is. 1. when we invoke a object Activation object will be created which will have references to prototype and constructor 2. prototype chain continues to supertype up till Object as every object extends Object 3. Finally Object prototype will have refrences to Global/Window Object right So is the sequence, activation Object Of instance ->supertype prototype -> Object prototype -> Global Window Object type correct ? Thank, Chandra
  18. Hi All, Why there are no classes in JS ? if there are no classes then how are we creating function objects examplefunction Person(){}var p = new Person(); we are instantiating a function instead of class, how can this happen and how is instanceof check passing if there are no classes ?If there were their then data and accessor properties could have been applied only once instead of defining them every time when the Object is created right?for example:var o={};Object.defineProperty(o,name,{ value : "testingNameProperty", writeable: false});if had class we could have configured this directly on class instead of object "o", which makes more sense,In this case, we have to define this every time the object is created.
  19. Hi, Prototypal inheritance advocates Approach: 2, where we wrap the parent prototype with new object, augment the constructor and then assign it to subType. However, in Approach : 1 I havedirectly assigned the prototype both instanceof and prototype checks have passed. function Person(){}Person.prototype.sayHi=function(){ return "hi";}function SubPerson(){}//Approach : 1 directly assign the prototypeSubPerson.prototype= Person.prototype; //Approach : 2 wrap it with the other object//var newObject= Object.create(Person.prototype); //newObject.constructor=SubPerson;//SubPerson.prototype=newObject;var subPersonInstance= new SubPerson();console.log( (subPersonInstance instanceof SubPerson) +" "+ (subPersonInstance instanceof Person));console.log( (SubPerson.prototype.isPrototypeOf(subPersonInstance)) +" "+ (Person.prototype.isPrototypeOf(subPersonInstance))); In that case, we can go by Approach : 1 right ? why to wrap it with new Object.Thanks
  20. Hi All, In the code below, function Person(){ var personProperty="personPropertyValue"; //1 this works fine this.getPersonProperty=function(){ return personProperty; //2. this gives undefined this.getPersonProperty=function(){ return this.personProperty; //3. this give method not found on object Person var getPersonProperty=function(){ return personProperty; } } var o= new Person(); alert(o.getPersonProperty()); In 1 and 2, this points to current object execution context which is o, so both should produce same result, but in 2 I think this.personProperty points to some other execution context. In 3 as there is no "this" reference however "var" should put this in the "o" object instance and it should still work right ? but they don't, what is happening here?
  21. Dear all, some help will be highly appreciated. I have a JS code that has a form for first name and last name. Ajax then communicates with a PHP script and gets back a message from PHP that thanks the user by stating the first and last names of user. The PHP message will show at the bottom of the form without having the page to refresh. The PHP message ensures a successful communication between JS and PHP via Ajax. The JS script:<!DOCTYPE html><html lang="en"><head><script>function ajax_post() {//create our XMLHttpRequest objectvar hr = new XMLHttpRequest();//create some variables we need to send to our PHP filevar url = "my_parse_file.php"; //name of the PHP parsing script.var fn = document.getElementById("first_name").value;var ln = document.getElementById("last_name").value;var vars = "firstname="+fn+"&lastname="+ln; //variables to be sent to PHP scritp.hr.open("post", url, true); //using the open method on XMLHttpRequest object.hr.setRequestHeader("Content_type", "application/x-www-form-urlencoded");// access the onreadystatechange event for the XMLHttpRequest object.hr.onreadystatechange = function() {if (hr.readyState == 4 && hr.status == 200) {var return_data = hr.responseText;document.getElementById("status").innerHTML = return_data;}}// send the data to PHPhr.send(vars);document.getElementById("status").innerHTML = "processing...";}</script></head><body><h2>Ajax Post to PHP and Get Return Data</h2>Your First Name: <input id="first_name" name="first_name" type="text" /><br /><br />Your Last Name: <input id="last_name" name="last_name" type="text" /><br /><br /><input name="myBtn" type="submit" value="Submit Data" onClick="javascript:ajax_post();" /><br /><br /><div id="status"></id></script></body></html>The PHP script:<?phpecho 'Thank you ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . ',says the PHP file.';?>I receive no message back from the PHP script as desired, only the word "processing...".As part of the debugging, I inserted:document.write("Ready State = "+hr.readyState + " Ready Status = "+hr.status);after: hr.onreadystatechange = function() {The message I got was: Ready State = 4 Ready Status = 0.I thought it meant changing the 200 to 0, but still didn't work.My system: Apache, PHP 5.5.9, Windows 64-bit OS, Windows 7
  22. Hi there. I'm a newbie JS learner and I would need help with some simple stuff. Tools:SkypeJSBin or similarI am friendly, easy and fun to work with. I doubt it would take more than 30-60 minutes to do this stuff and maybe we can work on some serious projects next time if we get along.Skype me preferrably at Skype User ID: viewtendence
  23. Hy, I tried to read filenames of zip file. I use the jszip libaray to see the fileneams and check name and type, BUT the libaray can't show me the size of files. or i don't know how i can see it. Does anybody knows a zip libary, which is easy to use? i don't want compress and uncompress, only read the files and their properties..... thank you
  24. This topic goal is to inknowledge each person who read the post and to hopefully coerce them into sharing by posting too.I'll like to start out with mentioning untiy. I just briefly look over it in wiki. Have anyone ever use it for web development?
  25. I am not a accomplished js programmer. I am trying to get JS to fill a input box with today's date when a button is clicked. I am using Google Chrome. For some reason the code causes a form submit which I do not want because I would like other form input fields to be able to be filled in. I have done quite a few other js forms and never had this problem. What am I doing wrong? <?phpecho "<HTML> <head> <script type='text/javascript'> function bankdate() { document.getElementById('bankdate').value=Date(); } function invoicedate() { var today = '2015-01-01'; document.getElementById('invoicedate').value=today; } </script> </head> <body> <form name='myform' action='some.php' method='get'> <input type='text' id='bankdate' name='bankdate' class='tcal' size='10' value=''> <button onclick='bankdate(); return false;'>Today</button><br>Bank date</br> <input type='text' id='invoicedate' name='invoicedate' class='tcal' size='10' value=''> <button onclick='invoicedate();return false;'>Today</button><br>Invoice date </br> <br> <button type=submit>save</button> <!-- save button --> <button type=button onclick="javascript:window.location='index.php';">cancel</button> <!-- cancel button --> <button type=button onClick="window.location='" . $_SERVER['PHP_SELF'] . "'">clear</button></td> <!-- clear button --> </form><br><br> </body></html>";?>
×
×
  • Create New...