Posts

javascript - Code to find absolute position of an element of DOM in Java -

i working on project in java . in project, have find absolute position of element of dom. don't know how this. i searched on net, found same javascript. found here . code this , function getposition(element) { var xposition = 0; var yposition = 0; while(element) { xposition += (element.offsetleft - element.scrollleft + element.clientleft); yposition += (element.offsettop - element.scrolltop + element.clienttop); element = element.offsetparent; } return { x: xposition, y: yposition }; } when try write code in java, offsetleft, offsettop variable not found. can tell me, how can write code in java? edit no. 1 is there method using jsoup same? there 2 methods giving position in jsoup: element.elementsiblingindex() node.siblingindex() (you can count of childs too) but there's no offsetleft or offsettop in jsoup

javascript - Submitting Data from tokeninput.js -

i have set https://github.com/loopj/jquery-tokeninput on 1 of web sites. i trying allow users of sites create list number of options give them.. once user done selecting items , click submit no values back. can let me know doing wrong.. html <div> <input type="text" id="demo-input" name="name" /> <input type="submit" value="submit" /> </div> js <script type="text/javascript"> $(document).ready(function() { $("#demo-input").tokeninput("json.php"); }); </script> php $name =$_post["name"]); this doing far around issue.. as user adds , removes items list using onadd , ondelete functions add id's hidden field .. once id's populated can use standard $_post[] command in php read values here sample of code else might have same issue html <div> <input type="text" id="list_of_ite...

Connect javascript and HTML -

i'm beginning learn javascript , , browser api. why, if press "save" button , pop window not appears in browser ? wrong? <label for="txtnome"><input id="txtnome" type="text" value=""/><br/></label> <label for="txtcognome"><input id="txtcognome" type="text" value=""/><br/></label> <button id="btnsalva"/>salva</button><br/> <script> var model = { nome: "mario", cognome: "rossi" }; var view = { txtnome: document.getelementbyid("txtnome"), txtcognome: document.getelementbyid("txtcognome"), btnsalva: document.getelementbyid("btnsalva") }; var controller; controller = { init: function () { view.txtnome.value = model.nome; view.txtcognome.value = model.cognome; view.btns...

JavaScript: passing built-in objects' methods as callback functions -

i've been working through eloquent javascript 's exercises , found out think odd. wrote trivial array-flattening piece of code: var arrays = [[1, 2, 3], [4, 5], [6]]; var out = arrays.reduce(function(acc, next){ return acc.concat(next); }); console.log(out); // → [1, 2, 3, 4, 5, 6] so far good. didn't seem pretty me, rewrote as: var arrays = [[1, 2, 3], [4, 5], [6]]; var my_concat = function(acc, next){ return acc.concat(next); } var out = arrays.reduce(my_concat); console.log(out); // → [1, 2, 3, 4, 5, 6] it better, need introduce function, anonymous or named, such basic thing? array.prototype.concat.call 's call signature need! feeling smart, rewrote code again: var arrays = [[1, 2, 3], [4, 5], [6]]; var out = arrays.reduce([].concat.call); // → typeerror: arrays.reduce not function (line 2) well, haven't turned out expected. error message seemed cryptic me. i decided investigate. works: var arrays = [[1, 2, 3], [4, 5], [6]]; var my_concat = fu...

c++ - string.find() doesn't return -1 -

the code below simple. know, if string::find() didn't find matches returns -1. reasons code below doesn't work. everytime run code endless loop. thank help! #include <string> #include <iostream> using namespace std; int main() { string text; text = "asdasd ijk asdasd"; string toreplace = "ijk"; cout<<text<<endl; int counter = 0; while ( text.find(toreplace) != -1) counter++; cout<<counter<<endl; system("pause"); } aside other answers correct, wanted add while loop have produced endless loop anyway. example: while(text.find(toreplace) != std::string::npos) counter++; will endless loop because keep trying find toreplace string in text , find (that's because find starts beginning of string each time). not intended.

restore backup database with out sql server management studio -

i have 1 database backup. now want install backup friend's system. his system not contain sql server management studio. how can install backup system, both using sql server 2005. statement 1: his system not contain sql server management studio statement 2: both using sql server 2005... doesn't above 2 statements contradict each other? update please ignore previous answer run following command on command promt: sqlcmd -e -s myserver –q “restore database [mydb] disk=’d:backupsmydb.bak(your backup databse file)’” i got refrence here

Can't connect with MySQL DB in CLI mode (Being connected in GUI Mode) in PHP -

i'm trying connect mysql in command line php script file. have file i'm running in gui mode, in command line mode giving me below error @ time of mysqli_connect: mysqlnd cannot connect mysql 4.1+ using old insecure authentication. please use administration tool reset password command set password = password('your_existing_password'). store new, , more secure, hash value in mysql.user. if user used in other scripts executed php 5.2 or earlier might need remove old-passwords flag my.cnf file i understand can update password. due reason, can't update old password new passwords. need connect mysql support of old password. again, mentioning same code working fine in gui mode not in cli mode on same server. how happening. has idea? can check php.ini files used web server , command line php? web server, create page phpinfo() , check location of php.ini file. once php.ini file location used web server, can execute php script command line u...