Wednesday, May 18, 2016

Javascript HTML - Firefox does not show default selected value on page load

Problem:
I have a web page where user will enter his/her Date of Birth by choosing from the Month, Day and Year List.
Date of Birth Drop Down List

Date of Birth will automatically be saved after clicking the Next button. Which I have verified successful.


When user clicked the back button, page should automatically select the previously entered Date of Birth. My Jquery library is jquery-1.12.3 and my jquery code is this:
 var dobth = $('#dobthOrig').val();  
 var comp = dobth.split('/');  
 var m = parseInt(comp[0], 10) - 1;  
 var d = parseInt(comp[1], 10);  
 var y = parseInt(comp[2], 10);      
 $('select.month option[value='+m+']').attr('selected','true');  
 $('select.day option[value='+d+']').attr('selected','true');  
 $('select.year option[value='+y+']').attr('selected','true');   

However, when user clicked the back button, the Date drop down displayed current date (which is the default date) and not the selected date. I checked thru Dev Tool of Firefox and correct value is selected but display is not.


Selected Day

Selected Month


Solution: 
 autocomplete="off"  
- I searched from forum that code
- But what worked perfectly for me is changing the "attr" attribute to "prop".
 $('select.month option[value='+m+']').prop('selected','selected');  
 $('select.day option[value='+d+']').prop('selected','selected');  
 $('select.year option[value='+y+']').prop('selected','selected');   

Thursday, April 14, 2016

Oracle Statement to extract fields that has numeric value

I have this data where users should input a description of profession. But one day, i found out that there are pure numeric entries. I need to query all record where PROFESSION column has numeric value.

Oracle Statement to extract fields that has numeric value

 SELECT EMPID, NAME, PROFESSION  
 FROM EMPLOYEE  
 WHERE REGEXP_LIKE(PROFESSION, '^[[:digit:]]+$')  

Tuesday, April 12, 2016

Add left and bottom border for iText Cell PDF

Code
So I have this PDF layout that a cell should have both left and bottom border. 
 PdfPCell row26cell_4 = new PdfPCell(row26Par_4);  
 row26cell_4.setBorder(Rectangle.BOTTOM);  
 row26cell_4.setBorder(Rectangle.RIGHT);  
 row26cell_4.setBorderWidth(.9f);  


Solution:
 PdfPCell row26cell_4 = new PdfPCell(row26Par_4);  
 row26cell_4.setBorder(Rectangle.RIGHT | Rectangle.BOTTOM);