1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Get ids of checked checkboxes

Discussion in 'JavaScript' started by qwikad.com, Sep 5, 2015.

  1. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #21
    When I try to adapt this into a the old script (the one you provided) it doesn't work for me. I am not sure if I am doing this right, that's why I am asking you to modify that script to insure it works. I can't make it work no matter how I try to implement this. It will take like 3 seconds for you.
     
    qwikad.com, Sep 7, 2015 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #22
    Well, if you REALLY insist on doing it using markup, I'd still urlencode it so as to not conflict thus:

    server-side:
    $markup = '<a href="' . $url . '>' . $row['adid'] . '</a>';
    echo 'value="', rawurlencode($markup), '"';
    Code (markup):
    client-side:
    function checkInputs() {
    	var newMarkup = '';
    	for (var i = 0; i < inputs.length; i++) {
    		newMarkup += decodeURIComponent(inputs[i].value);
    	}
    	output.innerHTML = newMarkup;
    }
    Code (markup):
    Just beware it's slow, bad practice, and uses WAY more CPU. It would in fact royally piss off many users.

    -- edit -- we're playing post tag here :p

    I'm currently on the laptop "on the road" as it were (forced daily bike rid to try and stave off the parkinsons) taking a break at FatDonalds -- but when I get back to the workstation I'll try to toss together a simple working demo of both methods, as well as adding in the select all / deselect all buttons and localstorage.

    Taking a ride for my health, so what do I do? I stop for a "Big Breakfast" -- could be worse, I could have gone to Dunkins.
     
    deathshadow, Sep 7, 2015 IP
  3. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #23
    Thank you, will be looking forward to your reply.

    McD's is great. I can take it once a month though. If I eat more than that - heartburns will torture me forever.
     
    qwikad.com, Sep 7, 2015 IP
  4. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #24
    Ultimately, I want something similar to what craigslist does. If you go: http://orlando.craigslist.org/search/jjj and add ads to your favorites they are added using either cookies or localstorage (if I am not mistaken), but it's definitely not done by sending the data to the database.

    Currently, you can add ads to favorites on my classifieds as well http://qwikad.com/0/posts/20-Income-Opps/290-Affiliate-Marketing/ , but the data of the selected ids (or values) is not displayed anywhere. The checkboxes stay checked using localstorage for Chrome / FF / Opera and cookies for IE9+. Once I have the option of displaying the checked checkboxes ids (or values) my next step would be finding a way of displaying that data not just from that one current page, but from anywhere where the ads have been added to favorites throughout different categories (pages) in one place. Granted, if computers are changed or cookies are cleared the data will be lost, but I don't concern myself with that.

    Maybe this whole thing is stupid, I don't know. Maybe storing the data in the DB would make more sense, but I am not sure about that. I believe https://www.gumtree.com/ does that and I hate it, because as a visitor (as opposed to a poster) I don't want to create an account with them to JUST add ads to favorites.
     
    qwikad.com, Sep 7, 2015 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #25
    You might offer a choice - because the problem with local storage is that you (as the provider) have no control over it. Hence, if a user deletes his local storage cache, his favorites / checked items will go away, and the user will have no way to restore that content.
     
    PoPSiCLe, Sep 7, 2015 IP
  6. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #26
    And I am fine with that. That's how it works over on craigslist. It's a dynamic content: ads get deleted, they expire, the get blocked by us, etc. So that option is for a temporary here and now use, whichever way you look at it. I don't think anyone will care to store their favorite ads for more than a week or two anyway.
     
    qwikad.com, Sep 7, 2015 IP
  7. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,151
    Likes Received:
    1,656
    Best Answers:
    29
    Trophy Points:
    475
    #27
    Works like a charm. Spent the last two days trying to figure it all out. Added uncheck all and localStorage options. All in pure javascript. No jquery.

    As an example, go to: http://qwikad.com/0/posts/20-Income-Opps/290-Affiliate-Marketing/ and scroll all the way to the bottom, there are two buttons there "Recently Viewed" and "Favorites". You can add a bunch of favorites to test it. Should work with all browsers including IE9+. Anything before IE9 will show the Recently Viewed option only.

    BIG, HUGE thanks @deathshadow

    PS if you just recently visited the site, you may want to reload the page to show new classes for the Recently Viewed / Favorites box.
     
    qwikad.com, Sep 8, 2015 IP