samedi 6 avril 2019

How to code a button to direct to another webpage and check a checkbox

I'm working on a simple html boostrap project and need a button (href or button) on my index.html that when I click it, it sends me to my contact.html page and check a checkbox. I'm making a list of products and when visitors see the item they want and click it, it can directs them to the contact page with the item already marked to complete the information for purchase (checking a checkbox). I'm very basic on html and css and have a nule knowledge about js, and I imagine that it can be done with a function, but haven't found a similar question anywhere to implement it.

In my own poor knowledge I have tried to direct my button to contact.html#item1 (where item1 represents the checkbox I want to be checked), obviously with no results.

This is part of the code I have (i have take out the divs and img tags to simplify the code):

<a href="contact.html#item1">I want popcandy!</a>
<a href="contact.html#item2">I want icecandy!</a>
<a href="contact.html#item3">I want spicecandy!</a>

And the buttons in the form of the contact.html page are something like this (the ones I needed to be checked with the above buttons):

<input id="item1" type="radio" name="item1" value="item1"><label for="popcandy">Popcandy</label>
<input id="item2" type="radio" name="item2" value="item2"><label for="icecandy">icecandy</label>

If you have any solution please let me know, I'm very grateful. Sorry for my english redaction mistakes. :)




Aucun commentaire:

Enregistrer un commentaire