## Random Unique Number ? Was: to Prevent Incorrect Data Deletion

Expand Messages
• ... Terpikirkan kalau pesan2 tersebut ditampilkan secara acak urutannya. Saya mencoba membuat generator number (nomer) acak yang unik pada rentang sesuai
Message 1 of 5 , Jun 17, 2010
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
diri ini.

Scriptnya sebagai berikut:

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,
'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 ?'],

for(var i in arInp){
var x=arInp[i];
if(x.id =='checkAll'){continue;};
if(x.checked){isChecked=1;break;}
}

for(var i=0;i<arRand.length;i++){
fnCancel();
}
}
fnLast();
}
};
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

--
http://blog.rindudendam.net
http://rindudendam.deviantart.com

• om, masukin aja ke array textnya, trus ntar tinggal textArray[ parseInt(Math.random()*max) % textArray.length ]; 2010/6/18 Fadjar Nurswanto
Message 2 of 5 , Jun 17, 2010
om,

masukin aja ke array textnya,
trus ntar tinggal textArray[ parseInt(Math.random()*max) % textArray.length ];

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
diri ini.

Scriptnya sebagai berikut:

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,
'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 ?'],

for(var i in arInp){
var x=arInp[i];
if(x.id =='checkAll'){continue;};
if(x.checked){isChecked=1;break;}
}

for(var i=0;i<arRand.length;i++){
fnCancel();
}
}
fnLast();
}
};
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

--
http://blog.rindudendam.net
http://rindudendam.deviantart.com

--
http://m.ferdianto.com/
Message 3 of 5 , Jun 17, 2010

--
http://blog.rindudendam.net
http://rindudendam.deviantart.com

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
> ];
>
>
>>
>>
>> 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
>> diri ini.
>>
>> Scriptnya sebagai berikut:
>>
>> 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,
>> '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
>> ?'],
>>
>> for(var i in arInp){
>> var x=arInp[i];
>> if(x.id =='checkAll'){continue;};
>> if(x.checked){isChecked=1;break;}
>> }
>>
>> for(var i=0;i<arRand.length;i++){
>> fnCancel();
>> }
>> }
>> fnLast();
>> }
>> };
>> 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
>>
>> --
>> http://blog.rindudendam.net
>> http://rindudendam.deviantart.com
>>
>>
>>
>
>
>
• btw, hampir lupa, Math.random menghasilkan float, ga perlu di parseInt, di Math.floor cukup randQuestion = arrAsk[ Math.floor( Math.random() * 100000 ) %
Message 4 of 5 , Jun 17, 2010
btw, hampir lupa,

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

On Fri, Jun 18, 2010 at 1:47 PM, Fadjar Nurswanto wrote:

--
http://blog.rindudendam.net
http://rindudendam.deviantart.com

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
> ];
>
>
>>
>>
>> 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
>> diri ini.
>>
>> Scriptnya sebagai berikut:
>>
>> 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,
>> '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
>> ?'],
>>
>> for(var i in arInp){
>> var x=arInp[i];
>> if(x.id =='checkAll'){continue;};
>> if(x.checked){isChecked=1;break;}
>> }
>>
>> for(var i=0;i<arRand.length;i++){
>> fnCancel();
>> }
>> }
>> fnLast();
>> }
>> };
>> 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
>>
>> --
>> http://blog.rindudendam.net
>> http://rindudendam.deviantart.com
>>
>>
>>
>
>
>

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

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

<*> 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/
• Mantab ... Terima kasih. -- Fadjar Nurswanto http://blog.rindudendam.net http://rindudendam.deviantart.com Sent from GLS Powered by RinduDendam PearlBerry®
Message 5 of 5 , Jun 18, 2010
Mantab ... Terima kasih.

--
http://blog.rindudendam.net
http://rindudendam.deviantart.com

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
>
> ];
>
> On Fri, Jun 18, 2010 at 1:47 PM, Fadjar Nurswanto<
> mailinglist@...> wrote:
>
>> Sudah dimasukkan ke variable arAsk.
>>
>> --
>> http://blog.rindudendam.net
>> http://rindudendam.deviantart.com
>>
>> 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
>>> ];
>>>
>>>
>>>>
>>>>
>>>> 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
>>>> diri ini.
>>>>
>>>> Scriptnya sebagai berikut:
>>>>
>>>> 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,
>>>> '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
>>>> ?'],
>>>>
>>>> for(var i in arInp){
>>>> var x=arInp[i];
>>>> if(x.id =='checkAll'){continue;};
>>>> if(x.checked){isChecked=1;break;}
>>>> }
>>>>
>>>> for(var i=0;i<arRand.length;i++){
>>>> fnCancel();
>>>> }
>>>> }
>>>> fnLast();
>>>> }
>>>> };
>>>> 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
>>>>
>>>> --
>>>> http://blog.rindudendam.net
>>>> http://rindudendam.deviantart.com
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>> ------------------------------------
>>