Month: April 2013

God’s abundant mercy has begotten us again to a living hope through the resurrection of Jesus.
1 Peter 1:3

” We’re all vulnerable to fantastic offers – to scams in reality pay off with nothing but trouble. We are offered false hope that ends in dashed dreams.”

I couldn’t agree more with the statement above. Astonished by how hurtful to learn the truth of being lied, how cruel to face the person who betrayed us, and how hard it is to move on and leave behind all those pains. But God is good and He gives us strength each new day.

I found myself crying in bed some nights, hoping my day would end and never have to wake up to face the cruelty of reality again. But every morning when i open up my eyes, I am grateful for being alive. I live on my life, not for myself, but for the Glory of God.

“There is one offer, however, that is genuine, though fantastic beyond belief. It’s the offer that God makes to us – salvation through faith in Jesus’s finished work on the cross: Believe on the Lord Jesus Christ, and you will be saved (Acts 16:31).

By saying YES to salvation, we can have hope, peace, forgiveness, incomparable riches, and redemption.

I am so glad to know you, Jesus Christ 🙂 Thank you for this BEST offer that you gave me.

So far,

So far,

Time is ticking and I have not start writing my report. I made a very cute Om-Nom (from Cut The Rope) yesterday 🙂 Happy! Like this page for more cute stuffs –

Om Nom

Anyway, today i finally solved the problem of unique entry in the table as well as removing item from the table.
Here are a few things that i learnt:

  1. To add items into array.
    array.push({var1: dataVar1, var2: dataVar2})
  2. To remove items from array – use splice() method for array.
    The splice() method adds/removes items to/from an array, and returns the removed item(s).
    index – required. specifies where to add/remove items
    howmany – required. number of items to be removed. If ‘0’, no items will be removed.
    item1…itemx – optional. new items to be added.
  3. To access array item.
  4. To display items in array.
    for (i-0; i<array.length; i++){
    $('#divID').append(array[i[.var1+' '+array[i].var2+'<br>');
  5. To show the ID of something.
    let say id of a row:
    var $thisID = $(this).closest('tr').attr('id');
  6. To show index on the table.
    var index = $('#status_table tbody tr').last().index() + 1; //index() starts from 0.
  7. Selector variable
    [refer here]
    impt note: local variable can be called outside its function if it is declared without “var” keyword – to be proven later.
  8. Selector Wildcard
    • $('[id*=xx]') -given string xx anywhere
    • $('[id^=xx]') -start with xx
    • $('[id$=xx]') -end with xx

Progress Update

It has been a long time since i last update on my Web App status. I have been working on displaying the status of the feedback from the system. Much work on jQuery. There are lots of problems encountered and i posted quite a few questions at Stack Overflow. I get some good solutions but not immediately. I feel gratitude towards those who have helped me along the way, including my colleagues.

The current status of my progress:

  • Able to show dropdown list.
  • User can select one option from the list (i scrapped off the multiple select as it is too cumbersome) and display a div assigned to it.
  •  User can key in the feedback number and it will be added dynamically into the table as new row.
  • User can delete those entries one by one in the table.
  • Those entries have their index number assigned dynamically too.
  • Feedback type can be shown on the table as well.
  • User can monitor the arming status optionArming Arming Feedback table Zone added Zone

Along the way, i have been facing lots of troubles but they are all solved now 🙂

  • unable to assign index number [SOLVED: var index = $(‘#status_table tbody tr’).last().index() +1; ]
  • unable to show div correctly [SOLVED:

    $('div.right > div').hide();
    var selector = '#' + $(this).val() + 'Text';
    }); ]

  • unable to show variable textInput [SOLVED: string concatenation problem]
  • unable to update variable textInput accordingly (from another option) [SOLVED: textInput =$(this).prev().('.TextInput').val();

This appears to work under certain sequence – see my problem here.


But i changed my program to if else condition now. i think it would be easier for myself to understand and to post and get to the server.]

  • unable to show the textInput or anything on the table. [SOLVED:
    textInput = $(this).parent().prev().find('.TextInput').val();
    See the post above].
  • unable to update the arming status [use setInterval(function(){ }, period) ]

Syntax Error

I am so vex trying and trouleshooting for the whole day! I lose my appetite and yet i feel like fainting right now. There is haze outside the office and i hate it!

Anyway, here is a brief update on what have i done in these dew days to my program. I added a new div on the right and a table in it to display the status of, say, a lamp. it works. i can switch the image of ON and OFF of the lamp. cool.
Then i added drop down list which allows me to multiselect. Then i link it to several checkboxes for each list option. cool. Then i realize it is impractical because i will need at least thousands of checkboxes. At the same time, i was able to add new row to the table when i check on the box and remove that row when i uncheck it. awesome.
Then i scrap off the checkbox and replace with text input. Okay, it is not as easy as obtaining the id of the checkbox and i have to get the value from user! let’s leave the validattion of data for now but hey i can’t get the .val() now! i posted my question on stackoverflow and some of their replies are quite hard for me to understand. oh well.

I am super hungry now!

the worst thing that always happen is when you refresh your browser and everything supposed to be hidden just showed up everywhere and you know what it means. you misplaced or forgot about a semicolon, curly bracket, a quotation mark somewhere somehow. and in the hundreds lines of codes, you have to recall which part did you edit and scrutinize through each line and character.
then you found one or suspect one, edit it, save it, send it over, refresh your browser and urgh, it is still the same. go through the process again. but the best thing is always after you found that stupid syntax error! yay.
why python IDLE doesn’t allow me to check :/
i think i should start using fiddle! it is so troublesome to scrolllllllll!

jQuery: How to display checkbox

Using jQuery mobile, this is how i display 4 checkboxes… “data-mini” simply make the font and box smaller.

<div data-role="fieldcontain" id="checkbox">
<fieldset data-role="controlgroup">
<input type="checkbox"  name="outputCB_1"  data-mini="true" />
<label for="outputCB_1">Checkbox 1</label>
<input type="checkbox"  name="outputCB_2"  data-mini="true" />
<label for="outputCB_2">Checkbox 2</label>
<input type="checkbox"  name="outputCB_3"  data-mini="true" />
<label for="outputCB_3">Checkbox3</label>
<input type="checkbox"  name="outputCB_4"  data-mini="true" />
<label for="outputCB_4">Checkbox 4</label>

jQuery: How to display a div after selected an option

After selecting an option (or more) from a dropdown list (or other), you may want to display some description or more options. What i do here is to display a div consisting of some checkboxes.
Here’s how i do it:


if ($('#choice_1').is(':selected')){

jQuery: How to do Multiple Select from Dropdown List

Often in live, we hope for choosing more choice rather than just now. No, this doesn’t apply for your marriage.

Anywhere this is how i did it in jQuery Mobile. *happy*

<div data-role="fieldcontain">
<label for="multiselect">Select Category</label>
<select name="multiselect" id="multiselect" data-native-menu="false" multiple="multiple" size="3">
<option value="1" id="1">Choice 1</option>
<option value="2" id="2">Choice 2</option>
<option value="3" id="3">Choice 3</option>

The keyword here is multiple=”multiple”. With this, you can select as many options as possible. “size” defines how many options are there.

Debugging in Python

I probably need to study this.

Python Conquers The Universe

As a programmer, one of the first things that you need for serious program development is a debugger.

Python has a debugger, which is available as a module called pdb (for “Python DeBugger”, naturally!). Unfortunately, most discussions of pdb are not very useful to a Python newbie — most are very terse and simply rehash the description of pdb in the Python library reference manual. The discussion that I have found most accessible is in the first four pages of Chapter 27 of the Python 2.1 Bible.

So here is my own personal gentle introduction to using pdb. It assumes that you are not using any IDE — that you’re coding Python with a text editor and running your Python programs from the command line.

Some Other Debugger Resources

  • For information on the IDLE interactive debugger, see the IDLE documentation
  • For information on the Wing IDE debugger, see…

View original post 2,053 more words

How to Reset HTML Form using jQuery

Reset button makes life easier but can be disastrous if you accidentally click on it. opps.

1. Create the reset button in HTML:
<input type ="reset" id="reset" value="Reset"/>
// id and value is your own choice. Value is what that appears on the button.

2. In your javascript:
//’#reset’ is the id that you set.

Note: (Special thanks to Michael for explanation on this little jQuery magic.) [0] is because it is getting a list from the selector. So now it is getting the zeroth item from the selector.