javascript

How to reset a form on AHAH drupal_jason call

This is how you can reset a form on a Drupal AHAH call by sending a JavaScript with the drupal_json call.

 

<?php
   $domaintable
= _get_domain_table($_POST['uid']);

  
$domaintable .= '<script type="text/javascript">
                    var domainForm = document.getElementById("domainuser-add-domain-form");
                    domainForm.reset();
                    </script>'
;

   return
drupal_json($domaintable);
   exit();
?>

How to toggle showing and hiding a table row with JavaScript cross browsers

This is how you can toggle showing and hiding a table row with JavaScript cross browsers. This works fine with Internet Explorer 8, Firefox 3 and Opera 10.

  function klToggle (rowid) {

    var togrow = document.getElementById(rowid);

    if(togrow.style.visibility == "collapse") {
      togrow.style.visibility = "visible";
      togrow.style.display = "table-row"; //if not a table row ' = "block"; '
     

    }else{
      togrow.style.visibility = "collapse";
      togrow.style.display = "none";
    }

  }

Select one element and mark it and unmark all other elements using JavaScript

This is how you select one element and mark it somehow and unmark all other elements using JavaScript. You have an unlimited list of rows, maybe div tags or table tr rows. On each row you have a button and you when you click that button you want some action to take place and one of those actions maybe is mark up or show some element in that row, but at the same time you want to unmark or hide all other elements.

You maybe have tried to use getElementsByClassName and found out that its not supported in all browser.

Countdown to event date by JavaScript

This JavaScript code returns a sentence telling you how many days there areleft to some event.

JavaScript basics

Some basic JavaScripts

<script type="text/javascript">
  document.write("Hello World!")
</script>

<html>
<body>

<script type="text/javascript">
document.write("This is my first JavaScript!");
</script>

</body>
</html>

Send the client to a new location / URL

<script type="text/javascript">
  window.location="http://www.zimplicit.se";
</script>
[/codefilter_code]

Write some text in the windows status bar

<script type="text/javascript">
  window.status="Some text in the status bar!!";
</script>

Return t