114 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for Troy

This is a simple to use, self-contained website slideshow utility. Do you have a monitor or TV setup in your lobby where you'd like to present web content automatically? With this HTML/Javascript page, simply edit an array of pages or "slides". You define a title, duration, and URL for each …

Member Avatar for PROSYS_1
1
15K
Member Avatar for jkon

I wanted to post something in Daniweb for a while but I didn't had anything new. Recently I decided to write a new implementation for websocket connections client side using Shared Web Workers. Shared Web Workers are supported today by most browsers for desktop but few for mobile devices , …

Member Avatar for jkon
2
457
Member Avatar for Fungus1487

I browsed google and found nothing so thought i would put my efforts up here. hope this all helps. this function will allow you to return the number of days between two dates minus saturdays and sundays. (including the start date)

Member Avatar for pritaeas
0
3K
Member Avatar for shilpa647

After page loading , when I click on the ellipsis , horizontal tabs transform from bottom of the product image . After opening of the tabs menu bar , first tab should open by default.I tried multiple solutions but none of them worked out.

0
209
Member Avatar for Tom_46
Member Avatar for serkan sendur

As usual i searched google to convert Decimal numbers to their Binary equivalents but i couldnt find any short algorithm for that matter. So here is mine..

Member Avatar for Deendayal_Hindu
1
3K
Member Avatar for paulkd

...was asked for some php file upload code, so I thought I would post some stripped down, barebones code that I use in admin/dashboard pages to add/change images associated with products. Please see attached image for folder setup. The code uses the [jQuery Form](http://malsup.com/jquery/form/) plugin by Mike Alsup. **index.php** has …

Member Avatar for NaReSh_12
1
11K
Member Avatar for AleMonteiro

Hello everybody. I'm starting to build an event calendar for employees in my company, and the first thing I needed was an working calendar to build from, so I wrote a simple one. Hope it can be usefull for someone. Cheers.

Member Avatar for Mike_40
3
2K
Member Avatar for rajesanthu

The Code Given is for only beginners in HTML 1.The code implements a simple login form 2.It checks whether the password and usernames are matching or not 3.While you are using replace the predefined username and password that I'v given that is replace "myuserid" and "mypswrd" with your own userid …

Member Avatar for nate_2
0
137K
Member Avatar for Troy III

Will work on latest:Chrome Safari Firefox Opera and all versions of IE. *(client notifications are for demonstration purposes only, and subject to designer decisions and modifications ) Can be used for size and mime-type restrictions. When mime-type is not an issue, accepting any kind of image format can be done …

Member Avatar for Troy III
2
3K
Member Avatar for Troy III

# Determine if a namespace/variable-name exists # ## Check for namespace existence in your environment variables and objects before writing to them. ## **Guess if "Book1.chapter22.paragraph37" exists without provoking errors and retrieve/send data if it exists with simplest JS expressions.** Call syntax: isNS( [string], [num] ); Example: var nsresult = …

Member Avatar for Troy III
0
308
Member Avatar for AleMonteiro

Hi all. This is somewhat the equivalent of .NET String.Format(String, Args); Usages: 'Hello {0}'.format('DaniWeb!'); String.format('{0} {1} {2}', 'Hi', 'Again', 'Good Fella'); String.format('Hello {prefix} {name}', { prefix: 'Sr.', name: 'HeyHeyHey'}); I know there's lots of String.formats out there(some simpler and some more complex), but this is the one i've been using …

2
396
Member Avatar for JorgeM

When users interact with your web page and processes, it is important to provide them with continuous feedback. Without the feedback, a user is left wondering if you page is actually processing work, frozen, or just not working. This is especially true when incorporating Ajax requests that take more than …

2
1K
Member Avatar for tekagami

**Introduction** Lets say you have a website with a mobile version and a desktop version. Pictures can be resized proportinally using css on either version. But not all html tags resize proportionally, for instance: iframes. **Javascript Function** includes: the *id* of the iframe, the *original width* and *original height* See …

Member Avatar for Hicaro_1
4
859
Member Avatar for <M/>

This is a pretty darn simple snippet that I learned from a site (don't remember the name). This is just the working Javascript which i managed to "easily" replicate :P Hopefully this will be useful for you guys. Note, this won't graph anything unless you have the html/css (i didn't …

Member Avatar for <M/>
0
213
Member Avatar for diafol

**// EDIT 2014-04-07 //** New version (1.0.3) posted at the [bottom](http://www.daniweb.com/web-development/php/code/476623/ajaxed-linked-dropdowns-select-fields-for-volatile-data#post2082327) Demo Page: http://demos.diafol.org/ajax-linked-dropdowns.php *********************************************** Hello All. Been playing around with more linked dropdowns (select form fields), following the code snippet posted for static-ish data [here](http://www.daniweb.com/web-development/php/code/475238/linked-dropdowns-select-fields-for-static-ish-data). The static-ish version is of limited use (or of no use!) if data in …

Member Avatar for diafol
3
1K
Member Avatar for jkon

Some weeks ago I posted this and I realized from the referrals that it may help to be as a code snippet. This is an example of getting products details from categories – subcategories using ajax call. I am fond of OOP and this is not , but I believe …

Member Avatar for pritaeas
1
3K
Member Avatar for josverhoeff

Hi, I thought I'd share this with you. If you want all fields on a web form to be emptied of ther initial value (if any) on focus and filled again with the initial value on blur. Works with jquery.

Member Avatar for JJenZz
0
246
Member Avatar for tekagami

Sometimes a css file wont load because of a slow connection or a conflict between scripts (or just any other reason). This specially problematic on mobile websites (looking at you IOS) where many standards are applied. So this little script will add a link tag to the head tag and …

Member Avatar for tekagami
0
256
Member Avatar for faysal.ishtiaq_1

This code snippet can be used to get the current time in 12 hour format using JS

0
2K
Member Avatar for Larrywaz

This piece of Java works perfectly so that onmouseover of the text an image is placed above the text, my problem is I can't come up with a piece of code for onmouseout to remove the image and restore the site to the way it was before the onmouseover. Right …

Member Avatar for Larrywaz
1
3K
Member Avatar for vegaseat

A simple way to create rainbow colored text on your web page. Just cut and paste the code into Notepad, save as Rainbow.htm and run it on your browser.

Member Avatar for Troy III
3
589
Member Avatar for tekagami

1) onkeyup send textarea values to script 2) converts textarea value to array 3) loops thru the array 4) uses regex to check if its an email address 5) changes inner html of recipient div

Member Avatar for LastMitch
1
371
Member Avatar for FutureWebDev

Not sure if I can do this but I'm reading through JavaScript: The Definitive Guide, and I'm going to be posting practice scripts that work. They may not make sense, but they work. I'd also like responses on how these simple snippets could be used and how they can be …

Member Avatar for LastMitch
0
230
Member Avatar for pavankumarr

<head runat="server"> <title>Untitled Page</title> <script type="text/javascipt"> function startDownload() { var url='E:files\\sample.pdf'; window.open(url,'Download'); } </script> </head> <body> <form id="form1" runat="server"> <script type="text/javascript"> function openPopup() { popupwindow=window.open("Form.aspx",'WinName','width=900,height=500,left=200,top=200'); } s=alert("show"); s1=setTimeout("startDownload()",10000); </script> <div> <a href="" onclick="openPopup();return false" target="_blank">Click here to view Brochure</a> </div> </form> </body>

Member Avatar for LastMitch
1
5K
Member Avatar for JorgeM

Here is my first attempt at creating a simple slideshow. Contributions to making this more efficient are welcomed! #jsFiddle --> [Demo](http://jsfiddle.net/wGnEm/1/)

Member Avatar for JorgeM
5
263
Member Avatar for ipster

#Web app state management# The current state of the user interface determines which application actions are enabled and thus which html elements are enabled for the user to invoke them. Classes are used in the html to indicate elements that need to be managed. Then jQuery is used to configure …

Member Avatar for LastMitch
2
355
Member Avatar for jstfsklh211

to create a new comboBox when you post your form checkbox_name will contain the selected value $(document).ready(function() { var cb = "checkbox_name"; comboBox(document.getElementById(cb+"CB"), cb); var sel = myForm.elements[cb+"_hold"]; sel.length = 0; //add options sel.options[sel.options.length] = new Option("text", "value"); }); <div id="checkbox_name"></div>

0
356
Member Avatar for Airshow

Tablesorter (currently v2.0.5) includes an "update" method. This method keeps a Tablesorter object up to date with dynamic changes made to its table(s). Like other Tablesorter methods "update" is implemented in the form of a custom event. A typical method call would be $table.trigger("update"); , where $table is a jQuery …

Member Avatar for punknroll
0
799
Member Avatar for Troy III

# This is a simple HTML String Sanitizing tool. # ## It allows a highly rich,- but safe - html content input to be published on your pages. ## **The script code is very light and to some degree customizable.** * This function takes care of blacklisted tags, which are …

Member Avatar for Troy III
2
270

The End.