Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Friday, April 20, 2012

[HTML][Javascript] Mailto + Subject and Body

When we create a link that points to our mail we commonly use this:
<a href="mailto:my_email@test.com">Send me your Feedback!</a>

How about adding a subject on the email? Yes, we can also do that.
<a href="mailto:my_email@test.com?subject=my subject">Send me your Feedback!</a>

How about adding an email content? Another check!
<a href="mailto:my_email@test.com?subject=my subject&body=my content here">
    Send me your Feedback!</a>

Tuesday, April 17, 2012

[Javascript] Checkbox Check/Uncheck All Toggle Switch

Checkbox are useful when you intend to use more than one response or data so what if the user want to check all the available info? This is where the toggle switch happened to be useful.

Here's the code:
<script language="javascript">
  function checkAll(list, tick)
  {
    for (i = 0; i < list.length; i++)
      list[i].checked = tick.checked? true:false
  }
</script>
<form id="mylist" name="list">
  <input type="checkbox" name="toggle" onclick="
    javascript:checkAll(document.list.check, this)" />All
  <input type="checkbox" name="check" value="one" />One
  <input type="checkbox" name="check" value="two" />Two
  <input type="checkbox" name="check" value="three" />Three
  <input type="checkbox" name="check" value="four" />Four
  <input type="checkbox" name="check" value="five" />Five
</form>

Result:
All One Two Three Four Five

Wednesday, April 4, 2012

[JavaScript] Determine Screen Resolution

Every wonder how to detect your computer's screen resolution? Using javascript, you can. Here's how:
<script>
  document.write('Screen Resolution: ' + 
    screen.width + " x " + screen.height);
</script>

Here's the sample result:

Monday, April 2, 2012

[PHP][Javascript] Detect if Cookies are Enabled or Disabled

When we create a website, there are some applications that needed for the cookies to be enabled. If the cookies are disabled then the user's must be inform that their cookies must be enabled. And to inform the users, we need to detect if the cookies are enabled or not.

Friday, March 2, 2012

[JavaScript] Display Symbols in Alert

Alerts are what we usually use to prompt users about something. And sometimes we need to prompt something like an email address. We all know that email address have the @ symbol. Most likely will just add the @ symbol but once checking your work, the alert box is empty or maybe some codes will show on the page.

The problem here is symbols won't show in alert boxes. The solution? you need to type its unicode value instead of the symbol itself.

So for @ symbol, its unicode value is \u0040.

For example, instead of...
alert('contact us at customer@service.com');

The code must be like this...
alert('contact us at customer\u0040service.com');

Note that not only symbols have unicode values, other characters also have such as letters.

To convert characters to unicode, click here.
Related Posts Plugin for WordPress, Blogger...