Hashim1's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Members
Active Posts:
19 (0.02 per day)
Joined:
13-June 12
Profile Views:
827
Last Active:
User is offline Feb 24 2014 03:59 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   Hashim1 has not set their status

Posts I've Made

  1. In Topic: Simple CSS Pseudo-Class Problem

    Posted 24 Feb 2014

    An update to this. It seems my problem boiled down to simply not understanding what the :active pseudoclass actually does. I'd gathered, from my initial research on it, that it applies when a page is clicked on, and took "active link" to mean the active page, i.e. the page the user is currently on, rather than the link currently being clicked. After posting this thread, I did some more research and realised I'd misunderstood. From then on, the problem was easily solved. I created a new ID called "current" and applied it to the relevant link on each individual page. This fulfilled my initial purpose of having the currently-selected page highlighted perfectly.

    Sorry for the misunderstanding, and thanks to all who have taken the time out to help. It really is appreciated. :)
  2. In Topic: Preventing Repeating Strings in Random String Generator

    Posted 24 Oct 2012

    View PostJMRKER, on 24 October 2012 - 03:00 PM, said:

    One last step might be to reload the initial array if you needed to repeat the random display list a second (or greater) time after you had stripped the saved array to the last element.


    I don't want to strip the array to the last element. I think you might be understanding what I'm trying to achieve here: sorry if I didn't explain it properly, here goes.

    How I want the script to work will be like this: the script has a number of elements in an array - my strings. When the page is, I want a random element from that array to print to the page. So far I've already done this. Then, and this is the part I'm having trouble with, when the page is next refreshed, I want to prevent the array element/string that was just selected, from being selected just this time: just to prevent repeat displaying of the same string in a row.

    I don't want any array elements to be permanently taken out from the array. Just wanted to confirm you understood this as in your post it seemed like you understood my post to mean that. :)

    View PostHashim1, on 24 October 2012 - 03:18 PM, said:

    View PostJMRKER, on 24 October 2012 - 03:00 PM, said:

    One last step might be to reload the initial array if you needed to repeat the random display list a second (or greater) time after you had stripped the saved array to the last element.


    I don't want to strip the array to the last element. I think you might be misunderstanding what I'm trying to achieve here: sorry if I didn't explain it properly, here goes.

    How I want the script to work will be like this: the script has a number of elements in an array - my strings. When the page is refreshed, I want a random element from that array to print to the page. So far I've already done this. Then, and this is the part I'm having trouble with, when the page is next refreshed, I want to prevent the array element/string that was just selected, from being selected again: just to prevent repeat displaying of the same string in a row.

    I don't want any array elements to be permanently taken out from the array. Just wanted to confirm you understood this as in your post it seemed like you understood my post to mean that. :)


    Corrections to last post in bold.
  3. In Topic: Preventing Repeating Strings in Random String Generator

    Posted 24 Oct 2012

    View PostDormilich, on 23 October 2012 - 12:49 PM, said:

    What I want to now do, is revise the script to ensure that the array element that was last called is not selected again: if a string was last printed to the screen, I don't want it to show again, I want one of the other strings to display.

    1) remove the string you do not want to show from the array.
    2) save the array (cookies, WebStorage)
    3) load array from storage device, select new random element
    4) repeat 1)
    [/quote]

    Okay, so just to confirm that I'm understanding these steps you mentioned.

    So, in the order you mentioned: first use a method like splice() to remove the string/array element from the array. Save the entire array of elements (is this correct?) into somewhere like the WebStorage. And finally, make it so that the next time the page is refreshed, the script loads the entire array saved last time, which the string that was selected last time will not be part of. And then repeat as many times as needed.

    Is that basically what you had in mind?
  4. In Topic: Preventing Repeating Strings in Random String Generator

    Posted 23 Oct 2012

    View PostDormilich, on 23 October 2012 - 01:44 PM, said:

    well, that’s almost a barebones description of what you have to code. there is not much to expand.

    e.g.

    Quote

    remove the string [element] you do not want to show [any more] from the array.

    how do you remove an element from an array in principle?
    - pop()
    - shift()
    - splice()
    (you can check out each method on the MDN website)


    Okay, after a little more reading up on Local Storage, the syntax actually seems to be pretty straightforward. I'm working on getting it into my code now. :)

    By the way, because Local Storage is HTML5, do I need a HTML5 DOCTYPE in my HTML document to run it? Or is it still supported even if my DOCTYPE is something like HTML 4.0?

    Also, I'm curious as to the technicalities of HTML5 Storage - I've never actually heard of it before this, yet all the sites I've come across having nothing but praise for it. I'm wondering where exactly the storage is on the client - where is everything stored? I'm pretty sure cookies are stored on a client machine's HDD, is it the same case with HTML5 WebStorage? Or is it something a little more advanced than that?

    Regarding the removing an element from an array, I think I'm understanding what you're saying. Basically, I want a line of code in my script which removes an element from an array after it has been selected at random. That then means that element cannot be selected at random again? But I'm slightly confused: after an element is removed from an array using Javascript, is that element restored to the array on page refresh? I'm assuming it must be, but if so, how would removing the element from the array help in the first place then - if it is restored on page refresh, which is when I want my array element that has already been selected not to be selected.

    I'm sorry if I sound a bit confused: it's cos I am. :L Having trouble getting my head around the concept, sorry.
  5. In Topic: Preventing Repeating Strings in Random String Generator

    Posted 23 Oct 2012

    View PostDormilich, on 23 October 2012 - 01:18 PM, said:

    if you want to have a (whatever) relation, you need to save data between pages. of which the aforementioned two possibilities are the easiest (and esp. WebStorage is dead easy).

    as you have said, there is no way for Javascript to access code (code, not data!) from a previous page.


    Okay, so what exactly is WebStorage? Never heard of it before tbh. From the little reading up I've just done on it, it seems to be an (better, according to W3 Schools) alternative to cookies?

    How complicated is the process of writing to WebStorage? Is it advanced Javascript? As mentioned in my original post, I'm really a beginner to JS: a clumsy intermediate, at best.

    Could you perhaps expand on those steps that you mentioned in your post? What exactly they involve, and maybe how to start going about doing what I want to do?

    Thanks.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Hashim1 hasn't added any friends yet.

Comments

Hashim1 has no profile comments yet. Why not say hello?