Loading ...
Sorry, an error occurred while loading the content.

Re: [id-js] Random Unique Number ? Was: to Prevent Incorrect Data Deletion

Expand Messages
  • Fadjar Nurswanto
    Sudah dimasukkan ke variable arAsk. -- Fadjar Nurswanto http://blog.rindudendam.net http://rindudendam.deviantart.com Sent from GLS Powered by RinduDendam
    Message 1 of 5 , Jun 17, 2010
    • 0 Attachment
      Sudah dimasukkan ke variable arAsk.

      --
      Fadjar Nurswanto
      http://blog.rindudendam.net
      http://rindudendam.deviantart.com
      Sent from GLS Powered by RinduDendam PearlBerry®

      On 06/18/2010 01:45 PM, herdian ferdianto wrote:
      > om,
      >
      > masukin aja ke array textnya,
      > trus ntar tinggal textArray[ parseInt(Math.random()*max) % textArray.length
      > ];
      >
      > 2010/6/18 Fadjar Nurswanto<mailinglist@...>
      >
      >>
      >>
      >> On 06/18/2010 12:28 AM, ferdhie wrote:
      >>> Emh.... Kalau di random gmn ya?
      >>>
      >>> If (confirm("...")&& Math.random()> 0.5) jadi ga statis.
      >>>
      >>>
      >> Terpikirkan kalau pesan2 tersebut ditampilkan secara acak urutannya.
      >> Saya mencoba membuat generator number (nomer) acak yang unik pada
      >> rentang sesuai dengan jumlah pesan tersedia. Tetapi hal ini
      >> mengakibatkan kadang2 script loop terus. Saya curiga ada yang salah pada
      >> diri ini.
      >>
      >> Scriptnya sebagai berikut:
      >>
      >> <html><head><script>
      >> var
      >> oDemo={
      >> _genUniqueNum : function(max){
      >> var hasil=[];
      >> for(var i=0;i<max;i++){
      >> var isfound=0,
      >> randNum=parseInt(Math.random()*max);
      >> for(var x=0;x<hasil.length;x++){
      >> if(hasil[x] == randNum){isfound=1;break;}
      >> }
      >> if(isfound){i--;}else{
      >> hasil.push(randNum);
      >> }
      >> }
      >> return hasil;
      >> },
      >> _getInp : function(){
      >> var oTbl=window.document.getElementById('demo');
      >> return oTbl.getElementsByTagName('input');
      >> },
      >> checkAll : function(o){
      >> var v=o.checked,
      >> arInp=this._getInp();
      >> for(var i in arInp){
      >> var x=arInp[i];
      >> if(x.id=='checkAll'){continue;};
      >> x.checked=v;
      >> }
      >> },
      >> actDelete : function(){
      >> var arInp=this._getInp(),isChecked=0,
      >> fnCancel=function(){alert('Delete file aborted.');},
      >> fnLast=function(){alert('Thank you for your patient.\n'+
      >> 'But, I dont trust you to delete the file(s).\n'+
      >> ' to prevent incorrect file(s) deletion this action aborted. :)');},
      >> arAsk=['Are you sure to delete the file(s) ?','Are you really sure to
      >> delete the file(s) ?','Please make sure the file(s) to delete. Have you
      >> ?'],
      >> arRand=this._genUniqueNum(arAsk.length);
      >>
      >> for(var i in arInp){
      >> var x=arInp[i];
      >> if(x.id =='checkAll'){continue;};
      >> if(x.checked){isChecked=1;break;}
      >> }
      >>
      >> if(!isChecked){alert('Please choose the file(s) to delete');return;}
      >> for(var i=0;i<arRand.length;i++){
      >> //for(var i=0;c<arAsk.length;c++){
      >> if(!confirm(arAsk[arRand[i]])){
      >> fnCancel();
      >> }
      >> }
      >> fnLast();
      >> }
      >> };
      >> </script><style>td.democ{width:30px;}</style></head><body><div><table
      >> border="1" id="demo" style="background-color: white; width:
      >> 100%;"><tbody><tr> <td class="democ"><input type="checkbox"
      >> id="checkAll" value="checkAll" onclick="oDemo.checkAll(this)"></td>
      >> <td>Filename</td> </tr>
      >> <tr> <td class="democ"><input type="checkbox" value="data 1"></td>
      >> <td>Data 1</td> </tr>
      >> <tr> <td class="democ"><input type="checkbox" value="data 2"></td>
      >> <td>Data 2</td> </tr>
      >> <tr> <td class="democ"><input type="checkbox" value="data 3"></td>
      >> <td>Data 3</td> </tr>
      >> </tbody></table><input type="button" value="Delete"
      >> onclick="oDemo.actDelete()">
      >> </div></body></html>
      >>
      >> Any suggestion
      >>
      >> --
      >> Fadjar Nurswanto
      >> http://blog.rindudendam.net
      >> http://rindudendam.deviantart.com
      >>
      >> Sent from GLS Powered by RinduDendam PearlBerry®
      >>
      >>
      >
      >
      >
    • herdian ferdianto
      btw, hampir lupa, Math.random menghasilkan float, ga perlu di parseInt, di Math.floor cukup randQuestion = arrAsk[ Math.floor( Math.random() * 100000 ) %
      Message 2 of 5 , Jun 17, 2010
      • 0 Attachment
        btw, hampir lupa,

        Math.random menghasilkan float, ga perlu di parseInt, di Math.floor cukup

        randQuestion = arrAsk[ Math.floor( Math.random() * 100000 ) % arrAsk.length ];

        On Fri, Jun 18, 2010 at 1:47 PM, Fadjar Nurswanto <mailinglist@...> wrote:
        Sudah dimasukkan ke variable arAsk.

        --
        Fadjar Nurswanto
        http://blog.rindudendam.net
        http://rindudendam.deviantart.com
        Sent from GLS Powered by RinduDendam PearlBerry®

        On 06/18/2010 01:45 PM, herdian ferdianto wrote:
        > om,
        >
        > masukin aja ke array textnya,
        > trus ntar tinggal textArray[ parseInt(Math.random()*max) % textArray.length
        > ];
        >
        > 2010/6/18 Fadjar Nurswanto<mailinglist@...>
        >
        >>
        >>
        >> On 06/18/2010 12:28 AM, ferdhie wrote:
        >>> Emh.... Kalau di random gmn ya?
        >>>
        >>> If (confirm("...")&&  Math.random()>  0.5) jadi ga statis.
        >>>
        >>>
        >> Terpikirkan kalau pesan2 tersebut ditampilkan secara acak urutannya.
        >> Saya mencoba membuat generator number (nomer) acak yang unik pada
        >> rentang sesuai dengan jumlah pesan tersedia. Tetapi hal ini
        >> mengakibatkan kadang2 script loop terus. Saya curiga ada yang salah pada
        >> diri ini.
        >>
        >> Scriptnya sebagai berikut:
        >>
        >> <html><head><script>
        >> var
        >> oDemo={
        >> _genUniqueNum : function(max){
        >> var hasil=[];
        >> for(var i=0;i<max;i++){
        >> var isfound=0,
        >> randNum=parseInt(Math.random()*max);
        >> for(var x=0;x<hasil.length;x++){
        >> if(hasil[x] == randNum){isfound=1;break;}
        >> }
        >> if(isfound){i--;}else{
        >> hasil.push(randNum);
        >> }
        >> }
        >> return hasil;
        >> },
        >> _getInp : function(){
        >> var oTbl=window.document.getElementById('demo');
        >> return oTbl.getElementsByTagName('input');
        >> },
        >> checkAll : function(o){
        >> var v=o.checked,
        >> arInp=this._getInp();
        >> for(var i in arInp){
        >> var x=arInp[i];
        >> if(x.id=='checkAll'){continue;};
        >> x.checked=v;
        >> }
        >> },
        >> actDelete : function(){
        >> var arInp=this._getInp(),isChecked=0,
        >> fnCancel=function(){alert('Delete file aborted.');},
        >> fnLast=function(){alert('Thank you for your patient.\n'+
        >> 'But, I dont trust you to delete the file(s).\n'+
        >> ' to prevent incorrect file(s) deletion this action aborted. :)');},
        >> arAsk=['Are you sure to delete the file(s) ?','Are you really sure to
        >> delete the file(s) ?','Please make sure the file(s) to delete. Have you
        >> ?'],
        >> arRand=this._genUniqueNum(arAsk.length);
        >>
        >> for(var i in arInp){
        >> var x=arInp[i];
        >> if(x.id =='checkAll'){continue;};
        >> if(x.checked){isChecked=1;break;}
        >> }
        >>
        >> if(!isChecked){alert('Please choose the file(s) to delete');return;}
        >> for(var i=0;i<arRand.length;i++){
        >> //for(var i=0;c&lt;arAsk.length;c++){
        >> if(!confirm(arAsk[arRand[i]])){
        >> fnCancel();
        >> }
        >> }
        >> fnLast();
        >> }
        >> };
        >> </script><style>td.democ{width:30px;}</style></head><body><div><table
        >> border="1" id="demo" style="background-color: white; width:
        >> 100%;"><tbody><tr>  <td class="democ"><input type="checkbox"
        >> id="checkAll" value="checkAll" onclick="oDemo.checkAll(this)"></td>
        >> <td>Filename</td>  </tr>
        >> <tr>  <td class="democ"><input type="checkbox" value="data 1"></td>
        >> <td>Data 1</td>  </tr>
        >> <tr>  <td class="democ"><input type="checkbox" value="data 2"></td>
        >> <td>Data 2</td>  </tr>
        >> <tr>  <td class="democ"><input type="checkbox" value="data 3"></td>
        >> <td>Data 3</td>  </tr>
        >> </tbody></table><input type="button" value="Delete"
        >> onclick="oDemo.actDelete()">
        >> </div></body></html>
        >>
        >> Any suggestion
        >>
        >> --
        >> Fadjar Nurswanto
        >> http://blog.rindudendam.net
        >> http://rindudendam.deviantart.com
        >>
        >> Sent from GLS Powered by RinduDendam PearlBerry®
        >>
        >>
        >
        >
        >



        ------------------------------------

        Yahoo! Groups Links

        <*> To visit your group on the web, go to:
           http://groups.yahoo.com/group/id-js/

        <*> Your email settings:
           Individual Email | Traditional

        <*> To change settings online go to:
           http://groups.yahoo.com/group/id-js/join
           (Yahoo! ID required)

        <*> To change settings via email:
           id-js-digest@yahoogroups.com
           id-js-fullfeatured@yahoogroups.com

        <*> To unsubscribe from this group, send an email to:
           id-js-unsubscribe@yahoogroups.com

        <*> Your use of Yahoo! Groups is subject to:
           http://docs.yahoo.com/info/terms/




        --
        http://m.ferdianto.com/
      • Fadjar Nurswanto
        Mantab ... Terima kasih. -- Fadjar Nurswanto http://blog.rindudendam.net http://rindudendam.deviantart.com Sent from GLS Powered by RinduDendam PearlBerry®
        Message 3 of 5 , Jun 18, 2010
        • 0 Attachment
          Mantab ... Terima kasih.

          --
          Fadjar Nurswanto
          http://blog.rindudendam.net
          http://rindudendam.deviantart.com
          Sent from GLS Powered by RinduDendam PearlBerry®

          On 06/18/2010 01:50 PM, herdian ferdianto wrote:
          > btw, hampir lupa,
          >
          > Math.random menghasilkan float, ga perlu di parseInt, di Math.floor cukup
          >
          > randQuestion = arrAsk[ Math.floor( Math.random() * 100000 ) % arrAsk.length
          > ];
          >
          > On Fri, Jun 18, 2010 at 1:47 PM, Fadjar Nurswanto<
          > mailinglist@...> wrote:
          >
          >> Sudah dimasukkan ke variable arAsk.
          >>
          >> --
          >> Fadjar Nurswanto
          >> http://blog.rindudendam.net
          >> http://rindudendam.deviantart.com
          >> Sent from GLS Powered by RinduDendam PearlBerry®
          >>
          >> On 06/18/2010 01:45 PM, herdian ferdianto wrote:
          >>> om,
          >>>
          >>> masukin aja ke array textnya,
          >>> trus ntar tinggal textArray[ parseInt(Math.random()*max) %
          >> textArray.length
          >>> ];
          >>>
          >>> 2010/6/18 Fadjar Nurswanto<mailinglist@...>
          >>>
          >>>>
          >>>>
          >>>> On 06/18/2010 12:28 AM, ferdhie wrote:
          >>>>> Emh.... Kalau di random gmn ya?
          >>>>>
          >>>>> If (confirm("...")&& Math.random()> 0.5) jadi ga statis.
          >>>>>
          >>>>>
          >>>> Terpikirkan kalau pesan2 tersebut ditampilkan secara acak urutannya.
          >>>> Saya mencoba membuat generator number (nomer) acak yang unik pada
          >>>> rentang sesuai dengan jumlah pesan tersedia. Tetapi hal ini
          >>>> mengakibatkan kadang2 script loop terus. Saya curiga ada yang salah pada
          >>>> diri ini.
          >>>>
          >>>> Scriptnya sebagai berikut:
          >>>>
          >>>> <html><head><script>
          >>>> var
          >>>> oDemo={
          >>>> _genUniqueNum : function(max){
          >>>> var hasil=[];
          >>>> for(var i=0;i<max;i++){
          >>>> var isfound=0,
          >>>> randNum=parseInt(Math.random()*max);
          >>>> for(var x=0;x<hasil.length;x++){
          >>>> if(hasil[x] == randNum){isfound=1;break;}
          >>>> }
          >>>> if(isfound){i--;}else{
          >>>> hasil.push(randNum);
          >>>> }
          >>>> }
          >>>> return hasil;
          >>>> },
          >>>> _getInp : function(){
          >>>> var oTbl=window.document.getElementById('demo');
          >>>> return oTbl.getElementsByTagName('input');
          >>>> },
          >>>> checkAll : function(o){
          >>>> var v=o.checked,
          >>>> arInp=this._getInp();
          >>>> for(var i in arInp){
          >>>> var x=arInp[i];
          >>>> if(x.id=='checkAll'){continue;};
          >>>> x.checked=v;
          >>>> }
          >>>> },
          >>>> actDelete : function(){
          >>>> var arInp=this._getInp(),isChecked=0,
          >>>> fnCancel=function(){alert('Delete file aborted.');},
          >>>> fnLast=function(){alert('Thank you for your patient.\n'+
          >>>> 'But, I dont trust you to delete the file(s).\n'+
          >>>> ' to prevent incorrect file(s) deletion this action aborted. :)');},
          >>>> arAsk=['Are you sure to delete the file(s) ?','Are you really sure to
          >>>> delete the file(s) ?','Please make sure the file(s) to delete. Have you
          >>>> ?'],
          >>>> arRand=this._genUniqueNum(arAsk.length);
          >>>>
          >>>> for(var i in arInp){
          >>>> var x=arInp[i];
          >>>> if(x.id =='checkAll'){continue;};
          >>>> if(x.checked){isChecked=1;break;}
          >>>> }
          >>>>
          >>>> if(!isChecked){alert('Please choose the file(s) to delete');return;}
          >>>> for(var i=0;i<arRand.length;i++){
          >>>> //for(var i=0;c<arAsk.length;c++){
          >>>> if(!confirm(arAsk[arRand[i]])){
          >>>> fnCancel();
          >>>> }
          >>>> }
          >>>> fnLast();
          >>>> }
          >>>> };
          >>>> </script><style>td.democ{width:30px;}</style></head><body><div><table
          >>>> border="1" id="demo" style="background-color: white; width:
          >>>> 100%;"><tbody><tr> <td class="democ"><input type="checkbox"
          >>>> id="checkAll" value="checkAll" onclick="oDemo.checkAll(this)"></td>
          >>>> <td>Filename</td> </tr>
          >>>> <tr> <td class="democ"><input type="checkbox" value="data 1"></td>
          >>>> <td>Data 1</td> </tr>
          >>>> <tr> <td class="democ"><input type="checkbox" value="data 2"></td>
          >>>> <td>Data 2</td> </tr>
          >>>> <tr> <td class="democ"><input type="checkbox" value="data 3"></td>
          >>>> <td>Data 3</td> </tr>
          >>>> </tbody></table><input type="button" value="Delete"
          >>>> onclick="oDemo.actDelete()">
          >>>> </div></body></html>
          >>>>
          >>>> Any suggestion
          >>>>
          >>>> --
          >>>> Fadjar Nurswanto
          >>>> http://blog.rindudendam.net
          >>>> http://rindudendam.deviantart.com
          >>>>
          >>>> Sent from GLS Powered by RinduDendam PearlBerry®
          >>>>
          >>>>
          >>>
          >>>
          >>>
          >>
          >>
          >>
          >> ------------------------------------
          >>
          >> Yahoo! Groups Links
          >>
          >>
          >>
          >>
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.