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

Sunday, October 16, 2011

Javascript (remove character outside bracket)

i want to extract some information from text
for example. My Name Is Abu (19) years old

final output is 19

searching thru i found this code


pattern = /([a-z]+)([0-9]+)([A-Z]+)([0-9]+)/;
subject = 'test1234TEST1234';
matches = subject.match(pattern);
match1 = matches[1];
match2 = matches[2];
match3 = matches[3];
match4 = matches[4];
alert(match1);
alert(match2);
alert(match3);
alert(match4);

this is near but cannot add spaces or bracket on regex search

finally i remove space using this code


bb = "AAA AAA AAA(asdasd0 )asdasd asdasd";alert(bb.replace(/[\(\) ]/g,""));



reference: http://lawrence.ecorp.net/inet/samples/regexp-format.php


Sunday, December 27, 2009

Memasukkan colum ke dalam table menggunakan javascript

Tujuan : Memasukkan kolum baru ke dalam table menggunakan javascript.

<table width="800" border="1" id="jadual">

<tr>
<td>&nbsp;</td>
</tr>
</table>
<script>
// Memasukkan hello world ke dalam table jadual
// By apis17
function insert_column(){
try {
var jadual = document.getElementById("jadual");
var baris = jadual.insertRow(0);
var kotak = baris.insertCell(0);
kotak.innerHTML = "Hello world!";
}
catch (ex) {
// mengesan javascript error
alert(ex);
}
}
</script>
<label>
<input onClick="javascript:insert_column();" type="submit" name="button" id="button" value="Submit">
</label>

Sunday, June 05, 2005

sending SMS via internet

i spend much time to set word counter under my sms web here.

Error: this.form has no properties (using firefox javascript console)

Error: Object required (using ie6 browser)
Code: 0

solution:
* forgot to place <form.... > </form> opening tags for textarea options.

finally my sms word counter working normally :)
Related Posts Plugin for WordPress, Blogger...