Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Monday, December 13, 2010

PHP SELF

some servers cannot support PHP_SELF, to be safe, use $_SERVER['PHP_SELF'];

Wednesday, December 1, 2010

How to use ArrayList in Java

How to use ArrayList in Java
Useful tips here, but it din mention the big frustration I have today when using ArrayList.
when reassigning the same array to an ArrayList, make sure to reinitialize the Array, or else all items inside the ArrayList will refer to the same array and u will have duplicates of the last Array

Object[] tempObj = new Object[3];
while ((s = br.readLine()) != null) {
if(c == (rowItems)){
c = 0;
tempObj = new Object[3];//REINITIALIZE HERE
}
//if (s != null && s.equals("")==false) {
tempObj[c] = s;
System.out.println("Line" + c + ": " + tempObj[c]);
//}
if (c == (rowItems - 1)) {
userData.add(tempObj);
System.out.println("Expected result: \'" + tempObj[0].toString() + "\', \'" + tempObj[1].toString() + "\', \'" + tempObj[2].toString() + "\'");
}
c++;
}

Wednesday, October 27, 2010

Dynamically create drop down list for maximum compatibility

The W3C DOM Level 2 HTML defines an add method for the select element object

but not for the options collection. However using that method is
difficult as IE implements the method with the same name with different
parameters.
If you simply want to add an option then using the DOM Level 0
var select = document.forms.formName.elements.selectName;
select.options[select.options.length] = new Option('text', 'value');

is much better in terms of browser compatibility.
[color=blue]
> anOption.innerText = "NewElement";[/color]

Firefox does not support the innerText property at all. For option
element objects you can set
anOption.text
[color=blue]
> anOption.Value = "99";[/color]

JavaScript is case sensitive, the property is named value and not Value.

Tuesday, October 26, 2010

Mozilla id attr issue

Mozilla seems to have problem when mixing small cap n big caps letter in the id attr, example <div id="txtVAns">, better use all small caps next time