dcsimg
www.webdeveloper.com
Results 1 to 11 of 11

Thread: [RESOLVED] Submit 'input text' to shuffle 'image array' ???

  1. #1
    Join Date
    Mar 2017
    Posts
    9

    resolved [RESOLVED] Submit 'input text' to shuffle 'image array' ???

    I can't get figure out how to get this text input to properly activate the random shuffle image array. It will activate it, but on initial click. I would like it to require validation from the user inputting and then submitting text.

    I apologize for uploading the script/html this way, but the forum won't let me make any posts with any HTML/script BB tags. please note that for 'img src="http://i.imgur.com/8bp6n2l.jpg" name="canvas",' the <'s have been replaced with ['s.




    var imagesArray = [
    'https://assets.entrepreneur.com/content/3x2/1300/20150827173347-test-google-adwords-campaign-search-engine-internet.jpeg',
    'https://yt3.ggpht.com/-DvvzUuiYGos/AAAAAAAAAAI/AAAAAAAAAAA/YoUb-VzIovA/s900-c-k-no-mo-rj-c0xffffff/photo.jpg',
    'https://www.google.com/logos/doodles/2015/tu-bav-2015-5651988540817408-hp2x.jpg',
    'https://www.google.com/doodle4google/images/splashes/featured.png',
    'http://www.onetechstop.net/wp-content/uploads/2016/01/google-logo.jpg',
    ];

    var usedImages = {};
    var usedImagesCount = 0;

    function displayImage(){

    var num = Math.floor(Math.random() * (imagesArray.length));
    if (!usedImages[num]){
    document.canvas.src = imagesArray[num];
    usedImages[num] = true;
    usedImagesCount++;
    if (usedImagesCount === imagesArray.length){
    usedImagesCount = 0;
    usedImages = {};
    }
    } else {
    displayImage();
    }
    }

    </script>

    <html>
    <head>
    <body>
    <center>
    <form name="imageForm">

    <tr align="center">
    <td><br><br><br><br><br><br><br><br><br><br>
    [img src="http://i.imgur.com/8bp6n2l.jpg" name="canvas" /]<br><br>
    </td>
    </tr>
    <tr>
    <td>
    <center>
    <input onclick="displayImage();" type="text" class="btn1" id = "textbox" size="60" ><br><br>
    <br/>

    </td>
    </tr>

    </table>
    </form>

    </head>
    </body>
    </html>



  2. #2
    Join Date
    Dec 2012
    Posts
    1,397
    but the forum won't let me make any posts with any HTML/script BB tags.
    Click "Go Advanced" bottom right. In the new window you find buttons for code, quote, etc on top.
    I can't get figure out how to get this text input to properly activate the random shuffle image array. It will activate it, but on initial click. I would like it to require validation from the user inputting and then submitting text.
    Unfortunately I do not completely understand what your intention is: The user should enter something in the text field. What? Anything and only required that the text field is not empty? Or should the string being entered fullfill some criteria?

  3. #3
    Join Date
    Mar 2017
    Posts
    9
    Click "Go Advanced" bottom right. In the new window you find buttons for code, quote, etc on top.
    Thank you my friend, and trust me, I have been trying to for a while... I see from this thread I am not the only one with this problem, and I spent hours trying to solve it before deciding to move on.

    Unfortunately I do not completely understand what your intention is: The user should enter something in the text field. What? Anything and only required that the text field is not empty? Or should the string being entered fullfill some criteria?
    The user can enter anything into the text field, as long as some text is entered and then submitted with the enter key. I do not need onInput... but I'm not sure what it is I do need!

  4. #4
    Join Date
    Mar 2017
    Posts
    9
    I've made a jsfiddle with a fuller expounded version of what I'm trying code, which still isn't that much, so maybe there's something there getting in the way... sadly, it doesn't want to run, even though it will in my regular host.

  5. #5
    Join Date
    Mar 2017
    Posts
    9
    Here is a jsfiddle that is up and running, idk why the other jsfiddle is failing to update.

  6. #6
    Join Date
    Mar 2017
    Posts
    9
    Once again, a better fiddle- https://jsfiddle.net/tv6rL23x/1/#&togetherjs=I6xzq5tAp6

    Really quite aggravating, these js hiccups

    notice how the submit button won't function unless there is text present. This is what I meant earlier.

  7. #7
    Join Date
    Dec 2012
    Posts
    1,397
    Does this mean that your issue is fixed?

  8. #8
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    4,810
    If you are asking for help, its only fair that you post your code here and not expect people to trawl around the internet for your scripts. BBForum code tags are not rocket science, you have an opening and closing tag much like HTML but with square brackets, in my signature you will find these references, its not hard to work it out...
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  9. #9
    Join Date
    Mar 2017
    Posts
    9
    I solved the problem myself, with the help from another forum. The BBCode on your forum is obviously broken so you might have an easier time working on that than going around playing the BBCode police.

  10. #10
    Join Date
    Mar 2017
    Posts
    9
    I spent hours trying to adjust my code to work with BBCode. The code was/is working fine with jsfiddle and every other host I tried. In the end, I was even able to post it here, without the BBCode, but I know that grey box around the code really means the world to you guys, so I won't be wasting your time or mine any longer! Adios!

  11. #11
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    4,810
    You obviously do not understand that all you [code] Your
    code
    in here
    [/code]

    to get an output of
    Code:
     Your
    code
    in here
    you place two tags, one opener and one closing tag around your code, you DO NOT convert your script or code you are posting in to a BB Code, thats just plain silly to try.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

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



Recent Articles