ss_blog_claim=a37b70f67cd872812717e1fce7e83301
Latest Posts »
Latest Comments »
Popular Posts »

Javascript Simple Call Form

Written by techieDan on March 25, 2008 – 9:56 am

Javascript isn’t that hard. Especially when you want to handle a simple form action. For example, most sites tells us how to do validation for regular expressions and the javascript for it, but what if one is a totally newbie to javascript and html.

Here I bring upon you some of my practices which somehow though, not as new as the new javascript version and standard, it still works.

<form name=’testForm’ method=’post’ action=’callAction.jsp’>
<table>
 <tr>
  <td>Username</td>
  <td>: <input type=’text’ name=’username’ value=”></td>
 </tr>
 <tr>
  <td colspan=2><input type=’button’ value=’submit’ onClick=’submitForm(this.form);’></td>
 </tr>
</table> 
</form>

Now the above is a sample form. Now how about the javascript. Yes, as can be seen the onClick function is by itself a javascript to call a method from javascript. Now what can be done. Seeing from here, the reason instead of using a submit button, an INPUT TYPE=’button’ is being used, so it’ll be easier to handle actions using javascript.

Now have a look at the javascript method that was called. Let’s say to submit this form and to display the alert of the username.

<script language=’javascript’>
   function submitForm(thisform) {
        alert(”You have submitted ” + thisform.username.value +
                ” as your username!”);
        thisform.submit();
   }
</script>

So this function is mighty straight forward. It’ll display the username as well as submit the form to wherever it was submitted to. In this case, the form is submitted to itself.

So there you have it. :)


Tags: ,
Posted in HTML, javascript | No Comments »

How to Write HTML Codes on Blog Posts

Written by techieDan on March 17, 2008 – 10:13 pm

Sometimes we wonder, how the heck one can write html codes on blogs, especially wordpress just for displaying purposes but without it affecting any codes on the blog page

This is where usage of <pre> tag comes in. Yes, by enclosing the html codes in <pre> tags, one can write html freely without displaying any changes in code.

Sample of pre TAG

<pre><font color=”#ff0000″>TEST</font></pre>

Of course the best possible way is for typing out < is by using ascii codes like &lt; which means less than. So that’s how I display some tags out in html. Need anymore clarification, drop me a line.

ps : > is symbol for &gt;


Tags:
Posted in HTML | No Comments »