Category Archives: Stack Overflow

Answer by Nasser Torabzade for I want a live change event in input text element

you can use keyup() event:

$('#someInput').keyup(function() {
    // Your code here
});

there is also an input event:

$('#someInput').on('input', function() { 
    // Your code here
});

as frnhr pointed out, it's better to use input event because: "input will handle any change - e.g. if you paste something in the field, input will trigger but keyup wont."

Answer by Nasser Torabzade for Read the click event of the anchor tag in fancybox 2 title

you are binding an event to an element that does not exist at the time of binding the event, that's not gonna work. you need to bind your event to a parent element that exists when document is ready.

$(PARENT_ELEMENT).on("click","#tb2fb",function(){
      alert("RIP");
});

safest way is to use body as PARENT_ELEMENT in above code.

Answer by Nasser Torabzade for Javascript: Display the result in a pop up message/message box

one approach is to have contents that you want to be popped up, in a div with display:node, then when the radio button is clicked, popup that dialog using a jQuery plugin like fancybox:

<div id="popup" style="display:none;">PLAYLIST</div>

$(document).ready(function(){
    $(RADIO_BUTTON_ELEMENT).click(function(){
        $("#popup").fancybox();
    }
});

Answer by Nasser Torabzade for Capture window state in a form,

I'm not sure, but this might be the answer: try to add your hidden field statically to html, with a null value. then set its value dynamically using jQuery:

<td align='left' width='100'>
<form action='print_plan.php' method='post' name='printplan' target='_blank'>
<input type='hidden' id='PlanNo' name='PlanNo' value='13' />
<input type='hidden' id='IDuser' name='IDuser' value='1' />
<input type='hidden' id='detCols' name='detCols' value='' />
<input name='Submit' type='image' value='print' title='Print Plan'  src='images/print.gif'
           alt='Print Plan' onclick='detailCols()' />
</form>
</td>

jQuery

$(document).ready(function(){
    $("#detCols").val(details);
});

which data structure stores data in "type:length:value" triplets?

Salam (means Hello) :)

parsing output of a third party script, which was stored in a MySQL database, I encountered data structures almost like JSON, but in a triplets of:

key_type:key_length:key_name;
value_type:value_length:value_contents;

this is a example of it:

a:1:{
    s:5:"title";
    s:28:"<div>This is item title</div>";
    s:9:"permalink";
    s:31:"http://example.com/post-88.aspx";
    s:7:"content";
    s:31:"<div>This is item content</div>";
    s:4:"meta";
    a:1:{
        s:4:"tags";
        s:22:"these, are, some, tags";
    }
}

I just want to know is this a common standard structure or something conventional created by this script developers?

which data structure stores data in "type:length:value" triplets?

Salam (means Hello) :)

parsing output of a third party script, which was stored in a MySQL database, I encountered data structures almost like JSON, but in a triplets of:

key_type:key_length:key_name;
value_type:value_length:value_contents;

this is a example of it:

a:1:{
    s:5:"title";
    s:28:"<div>This is item title</div>";
    s:9:"permalink";
    s:31:"http://example.com/post-88.aspx";
    s:7:"content";
    s:31:"<div>This is item content</div>";
    s:4:"meta";
    a:1:{
        s:4:"tags";
        s:22:"these, are, some, tags";
    }
}

I just want to know is this a common standard structure or something conventional created by this script developers?

Node.js Unhandled ‘error’ event when using http.createServer().listen() on Ubuntu 12.04

Salam (means Hello) :)

I've developed a node.js script on my windows seven machine and it's working fine. but when I run it on my Ubuntu 12.04, the following error shows up and halts my app:

    throw er; // Unhandled 'error' event
              ^
Error: listen EACCES
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1020:19)
    at listen (net.js:1061:10)
    at Server.listen (net.js:1127:5)
    at Object.start (/httpServer/httpServer.js:9:34)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

and the point that caused error is .listen(80) in this line:

http.createServer(onRequest).listen(80); 
                             ^

I've also tried some other port numbers (like 100, 300, 500,...) instead of 80 and the error was still the same.

Node.js Unhandled ‘error’ event when using http.createServer().listen() on Ubuntu 12.04

Salam (means Hello) :)

I've developed a node.js script on my windows seven machine and it's working fine. but when I run it on my Ubuntu 12.04, the following error shows up and halts my app:

    throw er; // Unhandled 'error' event
              ^
Error: listen EACCES
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1020:19)
    at listen (net.js:1061:10)
    at Server.listen (net.js:1127:5)
    at Object.start (/httpServer/httpServer.js:9:34)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

and the point that caused error is .listen(80) in this line:

http.createServer(onRequest).listen(80); 
                             ^

I've also tried some other port numbers (like 100, 300, 500,...) instead of 80 and the error was still the same.

installing nodejs on ubuntu 12.10

Salam (means hello) :)

I'm trying to install node.js on my ubuntu 12.04 desktop. I've downloaded node package and followed readme file, ./configure and make commands worked fine, but make install command results in this:

nasser@nasser-pc:~/Downloads/node-v0.10.21$ sudo make install
[sudo] password for nasser: 
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory `/home/nasser/Downloads/node-v0.10.21/out'
  g++ '-DENABLE_DEBUGGER_SUPPORT' '-DENABLE_EXTRA_CHECKS' '-DV8_TARGET_ARCH_IA32' -I../deps/v8/src  -Wall -Wextra -Wno-unused-parameter -pthread -m32 -fno-strict-aliasing -O2 -fno-strict-aliasing -fno-tree-vrp -fno-rtti -fno-exceptions -MMD -MF /home/nasser/Downloads/node-v0.10.21/out/Release/.deps//home/nasser/Downloads/node-v0.10.21/out/Release/obj.target/v8_base/deps/v8/src/accessors.o.d.raw  -c -o /home/nasser/Downloads/node-v0.10.21/out/Release/obj.target/v8_base/deps/v8/src/accessors.o ../deps/v8/src/accessors.cc
make[1]: g++: Command not found
make[1]: *** [/home/nasser/Downloads/node-v0.10.21/out/Release/obj.target/v8_base/deps/v8/src/accessors.o] Error 127
make[1]: Leaving directory `/home/nasser/Downloads/node-v0.10.21/out'
make: *** [node] Error 2

installing nodejs on ubuntu 12.10

Salam (means hello) :)

I'm trying to install node.js on my ubuntu 12.04 desktop. I've downloaded node package and followed readme file, ./configure and make commands worked fine, but make install command results in this:

nasser@nasser-pc:~/Downloads/node-v0.10.21$ sudo make install
[sudo] password for nasser: 
make -C out BUILDTYPE=Release V=1
make[1]: Entering directory `/home/nasser/Downloads/node-v0.10.21/out'
  g++ '-DENABLE_DEBUGGER_SUPPORT' '-DENABLE_EXTRA_CHECKS' '-DV8_TARGET_ARCH_IA32' -I../deps/v8/src  -Wall -Wextra -Wno-unused-parameter -pthread -m32 -fno-strict-aliasing -O2 -fno-strict-aliasing -fno-tree-vrp -fno-rtti -fno-exceptions -MMD -MF /home/nasser/Downloads/node-v0.10.21/out/Release/.deps//home/nasser/Downloads/node-v0.10.21/out/Release/obj.target/v8_base/deps/v8/src/accessors.o.d.raw  -c -o /home/nasser/Downloads/node-v0.10.21/out/Release/obj.target/v8_base/deps/v8/src/accessors.o ../deps/v8/src/accessors.cc
make[1]: g++: Command not found
make[1]: *** [/home/nasser/Downloads/node-v0.10.21/out/Release/obj.target/v8_base/deps/v8/src/accessors.o] Error 127
make[1]: Leaving directory `/home/nasser/Downloads/node-v0.10.21/out'
make: *** [node] Error 2