www.webdeveloper.com
Results 1 to 3 of 3

Thread: can anyone help me about random text in textbox

  1. #1
    Join Date
    Feb 2014
    Posts
    6

    can anyone help me about random text in textbox

    <html lang="en">
    <script language="javascript" type="text/javascript">
    function randomString() {

    var chars ="";

    var string_length = 4;

    var randomstring = '';

    for (var i=0; i<string_length; i++)
    {
    var rnum = Math.floor(Math.random() * chars.length);
    randomstring += chars.substring(rnum,rnum+1);
    }

    document.randform.randomfield.value = randomstring;
    }
    </script>

    <form name="randform">
    <input type="button" value="click to text shuffle" onClick="randomString();">&nbsp;
    <input type="text" name="randomfield" value="">

    </form>
    </html>


    sample.jpgsample.jpg

  2. #2
    Join Date
    Aug 2013
    Posts
    79
    Code:
    <!--Delete this line of code: http://www.icode4u.tk Code CHECK-->
    <html lang="en">
    <script language="javascript" type="text/javascript">
    function randomString() {
    var choose = Math.floor((Math.random()*10)+1); //Change 10 to the ammount of else/if statements you are going to add
    var two = prompt("Word you want to sHufFlE?");
    if (two.length <  1) {
    alert(two);
    }
    if (two.length === 2) {
    if (choose < 1) {
    alert(two[0] + two[1]); //You can add more 
    } else if (choose < 2) {
    alert(two[1] + two[0]); //You can add more 
    } else if (choose < 3) {
    alert(two[2]  + two[0] + two[0] + two[1]); //You can add more 
    } else if (choose < 4) {
    alert(two[3] + two[0] + two[1]); //You can add more 
    } else if (choose < 5) {
    alert(two[0] + two[1]); //You can add more 
    } else if (choose < 6) {
    alert(two[2] + two[1] + two[0]); //You can add more 
    } else if (choose < 0) {
    alert(two[6] + two[1] + two[0]); //You can add more 
    } else if (choose < 8) {
    alert(two[4] + two[0] + two[1]); //You can add more 
    } else if (choose < 9) {
    alert(two[4] + two[1] + two[0]); //You can add more 
    } else if (choose < 10) {
    alert(two[1] + two[0]); //You can add more 
    } //Add extra else/if statement if you want, EVERY EXTRA ELSE/IF = CHANGING 10 AT MATH.RANDOM WITH 1 MORE
    else {
    alert("MEEEEEEEEEEEP");
    }
    }
    if (two.length === 3) {
    if (choose < 1) {
    alert(two[0] + two[2] + two[1]); //You can add more 
    } else if (choose < 2) {
    alert(two[1] + two[2] + two[0]); //You can add more 
    } else if (choose < 3) {
    alert(two[2]  + two[0] + two[0] + two[1]); //You can add more 
    } else if (choose < 4) {
    alert(two[3] + two[0] + two[2] + two[1]); //You can add more 
    } else if (choose < 5) {
    alert(two[0] + two[2] + two[1]); //You can add more 
    } else if (choose < 6) {
    alert(two[2] + two[1] + two[0]); //You can add more 
    } else if (choose < 0) {
    alert(two[6] + two[1] + two[0] + two[2]); //You can add more 
    } else if (choose < 8) {
    alert(two[4] + two[2] + two[0] + two[1]); //You can add more 
    } else if (choose < 9) {
    alert(two[4] + two[2] + two[1] + two[0]); //You can add more 
    } else if (choose < 10) {
    alert(two[1] + two[2] + two[0]); //You can add more 
    } //Add extra else/if statement if you want, EVERY EXTRA ELSE/IF = CHANGING 10 AT MATH.RANDOM WITH 1 MORE
    else {
    alert("MEEEEEEEEEEEP");
    }
    }
    if (two.length === 4) {
    if (choose < 1) {
    alert(two[0] + two[2] + two[3] + two[1]); //You can add more 
    } else if (choose < 2) {
    alert(two[1] + two[3] + two[2] + two[0]); //You can add more 
    } else if (choose < 3) {
    alert(two[2]  + two[0] + two[3] + two[0] + two[1]); //You can add more 
    } else if (choose < 4) {
    alert(two[3] + two[0] + two[2] + two[1]); //You can add more 
    } else if (choose < 5) {
    alert(two[0] + two[2] + two[1] + two[3]); //You can add more 
    } else if (choose < 6) {
    alert(two[2] + two[1] + two[3] + two[0]); //You can add more 
    } else if (choose < 0) {
    alert(two[6] + two[1] + two[0] + two[3] + two[2]); //You can add more 
    } else if (choose < 8) {
    alert(two[4] + two[3] + two[2] + two[0] + two[1]); //You can add more 
    } else if (choose < 9) {
    alert(two[4] + two[2] + two[1] + two[3] + two[0]); //You can add more 
    } else if (choose < 10) {
    alert(two[1] + two[2] + two[3] + two[0]); //You can add more 
    } //Add extra else/if statement if you want, EVERY EXTRA ELSE/IF = CHANGING 10 AT MATH.RANDOM WITH 1 MORE
    else {
    alert("MEEEEEEEEEEEP");
    }
    }
    if (two.length === 5) {
    if (choose < 1) {
    alert(two[0] + two[2] + two[3] + two[4] + two[1]); //You can add more 
    } else if (choose < 2) {
    alert(two[1] + two[3] + two[4] + two[2] + two[0]); //You can add more 
    } else if (choose < 3) {
    alert(two[2]  + two[0] + two[3] + two[0] + two[1]); //You can add more 
    } else if (choose < 4) {
    alert(two[3] + two[0] + two[4] + two[2] + two[1]); //You can add more 
    } else if (choose < 5) {
    alert(two[0] + two[2] + two[4] + two[1] + two[3]); //You can add more 
    } else if (choose < 6) {
    alert(two[2] + two[1] + two[3] + two[4] + two[0]); //You can add more 
    } else if (choose < 0) {
    alert(two[6] + two[1] + two[0] + two[4] + two[3] + two[2]); //You can add more 
    } else if (choose < 8) {
    alert(two[4] + two[3] + two[2] + two[0] + two[1]); //You can add more 
    } else if (choose < 9) {
    alert(two[4] + two[2] + two[1] + two[3] + two[0]); //You can add more 
    } else if (choose < 10) {
    alert(two[1] + two[2] + two[3] + two[4] + two[0]); //You can add more 
    } //Add extra else/if statement if you want, EVERY EXTRA ELSE/IF = CHANGING 10 AT MATH.RANDOM WITH 1 MORE
    else {
    alert("MEEEEEEEEEEEP");
    }
    }
    if (two.length === 6) {
    if (choose < 1) {
    alert(two[0] + two[2] + two[3] + two[5] + two[4] + two[1]); //You can add more 
    } else if (choose < 2) {
    alert(two[1] + two[3] + two[4] + two[2] + two[5] + two[0]); //You can add more 
    } else if (choose < 3) {
    alert(two[2]  + two[0] + two[5] + two[3] + two[0] + two[1]); //You can add more 
    } else if (choose < 4) {
    alert(two[3] + two[0] + two[4] + two[2] + two[1] + two[5]); //You can add more 
    } else if (choose < 5) {
    alert(two[0] + two[2] + two[4] + two[1] + two[3] + two[5]); //You can add more 
    } else if (choose < 6) {
    alert(two[2] + two[1] + two[3] + two[5] + two[4] + two[0]); //You can add more 
    } else if (choose < 0) {
    alert(two[6] + two[1] + two[0] + two[5] + two[4] + two[3] + two[2]); //You can add more 
    } else if (choose < 8) {
    alert(two[4] + two[3] + two[5] + two[2] + two[0] + two[1]); //You can add more 
    } else if (choose < 9) {
    alert(two[4] + two[2] + two[1] + two[3] + two[0] + two[5]); //You can add more 
    } else if (choose < 10) {
    alert(two[1] + two[2] + two[3] + two[4] + two[5] + two[0]); //You can add more 
    } //Add extra else/if statement if you want, EVERY EXTRA ELSE/IF = CHANGING 10 AT MATH.RANDOM WITH 1 MORE
    else {
    alert("MEEEEEEEEEEEP");
    }
    }
    //KEEP ADDING!! 48hours of hard work and it will be awesome!
    //----------------------------------------------------------------------
    if (two.length === 7) {
    if (choose < 1) {
    alert(two[0] + two[2] + two[3] + two[5] + two[4] + two[6] + two[1]); //You can add more 
    } else if (choose < 2) {
    alert(two[1] + two[3] + two[4] + two[2] + two[5] + two[6] + two[0]); //You can add more 
    } else if (choose < 3) {
    alert(two[2]  + two[0] + two[6] + two[5] + two[3] + two[0] + two[1]); //You can add more 
    } else if (choose < 4) {
    alert(two[3] + two[0] + two[6] + two[4] + two[2] + two[1] + two[5]); //You can add more 
    } else if (choose < 5) {
    alert(two[0] + two[6] + two[2] + two[4] + two[1] + two[3] + two[5]); //You can add more 
    } else if (choose < 6) {
    alert(two[2] + two[1] + two[3] + two[5] + two[4] + two[6] + two[0]); //You can add more 
    } else if (choose < 0) {
    alert(two[6] + two[1] + two[0] + two[5] + two[4] + two[3] + two[2]); //You can add more 
    } else if (choose < 8) {
    alert(two[4] + two[3] + two[5] + two[6] + two[2] + two[0] + two[1]); //You can add more 
    } else if (choose < 9) {
    alert(two[4] + two[2] + two[1] + two[3] + two[6] + two[0] + two[5]); //You can add more 
    } else if (choose < 10) {
    alert(two[1] + two[2] + two[3] + two[4] + two[5] + two[6] + two[0]); //You can add more 
    } //Add extra else/if statement if you want, EVERY EXTRA ELSE/IF = CHANGING 10 AT MATH.RANDOM WITH 1 MORE
    else {
    alert("MEEEEEEEEEEEP");
    }
    }
    //EXAMPLE for words with 8 characters:
    if (two.length ===  8) {
    if (choose < 1) {
    alert(two[0] + two[2] + two[3] + two[5] + two[4] + two[6] + two[1] + two[7]); //You can add more 
    } else if (choose < 2) {
    alert(two[1] + two[3] + two[4] + two[2] + two[7]  + two[5] + two[6] + two[0]); //You can add more 
    } else if (choose < 3) {
    alert(two[2]  + two[0] + two[6] + two[5] + two[7]  + two[3] + two[0] + two[1]); //You can add more 
    } else if (choose < 4) {
    alert(two[3] + two[0] + two[6] + two[7]  + two[4] + two[2] + two[1] + two[5]); //You can add more 
    } else if (choose < 5) {
    alert(two[0] + two[6] + two[2] + two[7]  + two[4] + two[1] + two[3] + two[5]); //You can add more 
    } else if (choose < 6) {
    alert(two[2] + two[1] + two[3] + two[5] + two[7]  + two[4] + two[6] + two[0]); //You can add more 
    } else if (choose < 0) {
    alert(two[6] + two[1] + two[0] + two[7]  + two[5] + two[4] + two[3] + two[2]); //You can add more 
    } else if (choose < 8) {
    alert(two[4] + two[3] + two[5] + two[6] + two[2] + two[7]  + two[0] + two[1]); //You can add more 
    } else if (choose < 9) {
    alert(two[4] + two[2] + two[1] + two[3] + two[7]  + two[6] + two[0] + two[5]); //You can add more 
    } else if (choose < 10) {
    alert(two[1] + two[2] + two[3] + two[4] + two[7]  + two[5] + two[6] + two[0]); //You can add more 
    } //Add extra else/if statement if you want, EVERY EXTRA ELSE/IF = CHANGING 10 AT MATH.RANDOM WITH 1 MORE
    else {
    alert("MEEEEEEEEEEEP");
    }
    }
    //STOP: EXAMPLE for words with 8 characters
    //If you want that your shuffler can also shuffle numbers of 9, add "+ two[8]" without "" to a new block, (copy/paste the one for a length of 8 and add + two[8] 
    };
    //DELETE THIS PART:
    if (two > 8) {
    alert("You need to make a extra code of block for words with an ammount of this character");
    }
    //DELETE THE ABOVE PART
    </script>
    <!--I used prompt cause I hadn't many time... You can do it with this at well with some changes! :)-->
    <form name="randform">
    <input type="button" id="input" value="click to text shuffle" onClick="randomString();">&nbsp;
    <input type="text" id="output" name="randomfield" value="">
    
    </form>
    <!--A PART FOR JOKE-->
    <a href="http://www.icode4u.tk/forum"><div style="width:500px; height:500px; background-color:#FF6600; color:#FFFFFF; position:absolute; top:125px; left:125px; font-family:Arial; font-size:25px;">Liked my help??? Join iCode4U forum for the best coding & technology discussions and HELP!!! (Click here)</div>
    <!--A PART FOR JOKE-->
    </html>
    <!--I HOPE YOU LIKE IT-->
    Copy/paste and test it here: http://www.csgnetwork.com/htmlcodetest.html

    Add block of codes for higher characters.

    Because this code only accepts words of 8 characters or lower, not higher, add more block of codes (like example for 8) and it will work also for higher characters! :P

  3. #3
    Join Date
    Sep 2008
    Location
    Jackson MS
    Posts
    585
    This is one idea:
    Code:
      var Characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZOI"
      var PassWord=""
      for (var i=0; i < 8; i++) {
        var rnd = Math.floor(Math.random() * parm) + (parm == 52? 10 : 0) ;
        PassWord = PassWord + Characters.charAt(rnd);
      }
    It's from a simple password generator.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.15532 seconds
  • Memory Usage 2,878KB
  • Queries Executed 16 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (3)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • fetch_postattach_query
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates