-1

My users select one, or multiple pages and then get a button which they can then bookmark. This would give them quick acces to the pages they selected in the form.

Clicking this bookmark will open all the pages the user selected at once.

Now, I have most of it working but I'm having trouble with making it "bookmarkable" is there any way to do this? Right now it's only bookmarking an empty submit button with no information saved in it at all.

This is my code:

<form>
    <input type="checkbox" id="site1" name="site1" value="site1">site1<br>
    <input type="checkbox" id="site2" name="site2" value="site2">site2<br>
    <input type="checkbox" id="site3" name="site3" value="site3">site3<br>
    <input type="checkbox" id="site4" name="site4" value="site4">site4
    <a href="#" onClick="validate(); return false;">Submit</a>
</form>

And my java:

function validate() {
        $(":checkbox:checked").each(function() {
        var sitename = $(this).val();
        window.open('http://www.' + sitename + '.com');
    });
    return false;
}

This code succesfully opens the selected pages but only when submit is clicked on the page itself. Any help is greatly appreciated!

Jongware
  • 22,200
  • 8
  • 54
  • 100
Wijnand M
  • 372
  • 1
  • 3
  • 12

1 Answers1

0

See this Fiddle

HTML:

<form>
    <input type="checkbox" id="site1" name="site1" value="site1">site1<br>
    <input type="checkbox" id="site2" name="site2" value="site2">site2<br>
    <input type="checkbox" id="site3" name="site3" value="site3">site3<br>
    <input type="checkbox" id="site4" name="site4" value="site4">site4
    <a id="validate" href="#">Submit</a>
</form>

JS

$("#validate").click(function(){
    $(":checkbox:checked").each(function() {
        var sitename = $(this).val();
        window.open('http://www.' + sitename + '.com');
    });
    return false;
});
DG.
  • 3,417
  • 2
  • 23
  • 28
Mohammad Masoudian
  • 3,483
  • 7
  • 27
  • 45
  • for some reason it doesn't link to anything now. Your fiddle does but my own page doesn't, Dreamweaver switches the, href and id around but that shouldn't be it. But even if it worked in my page. Would bookmarking this submit button remember the entire form? – Wijnand M May 17 '14 at 15:29