javascript - Adding an input match-randomizer with JS / jQuery? V.2 -


i trying make basic randomizer can match things. sort of date(romance) picker, different situation.

i want product this:

(user input a1)

(user input a2)

(user input a3)

(user input b1)

(user input b2)

(user input b3)

where input randomly matches b input, never matches a, , doesn't randomize.

so looks this:

a1 - (b#)

a2 - (b#)

a3 - (b#)

problem is, suck @ js. take classes on codecademy, being html / css / jquery. keep trying different things, keep failing. can me?


html:

<!doctype html> <html> <head> <link class="jsbin"             href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">                </script>     <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script> <meta charset=utf-8 /> </head> <body>   <ul id="people"> people   <li>1</li>   <li>2</li>   <li>3</li>   <li>4</li>   <li>5</li>   <li>6</li>   <li>7</li>   <li>8</li>   <li>9</li>   </ul> <hr /> <ul id="jobs"> jobs   <li><input></input></li>   <li><input></input></li>   <li><input></input></li>   <li><input></input></li>   <li><input></input></li>   <li><input></input></li>   <li><input></input></li>   <li><input></input></li>   <li><input></input></li>   </ul> </body> </html> 

js:


$(document).ready(function () {     $('#jobs').find('li').shuffle();     var mynewlist = '';     $('#people').find('li').each(function (index) {         var jb = $('#jobs').find('li').eq(index);         mynewlist += '<li>person:' +  $(this).text() + ' job:' + jb.text() + '</li>';     });     $(mynewlist).appendto('#newlist'); }); 

http://jsbin.com/ijotok/6/edit

this have.

i want inputs randomize, doesn't work.

using code these posts:

i updated jsbin code 1 possible implementation http://jsbin.com/ijotok/8/

your present implementation has several issues it, 1 of them being you're executing code page loads, nothing triggering suffling once have provided input values. secondly shuffle not built jquery (that's why uncaught typeerror: object [object object] has no method 'shuffle', why added shufflearray function. add jquery plugin if needed (check out this plugin). third, you're accessing content of <li> .text(), should calling .val() on inputs.

take @ implementation , let me know if have questions.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -