0

I'm having a bit of trouble figuring out the jquery (or javascript) syntax for an unsubscribe form.

The project entails the following:

I no longer wish to receive:

(1) Information related to product A

(2) Information about any production from Company A1 (Company A1 also own product A)

(Submit)

Please keep in mind I have not been provided a field for the visitor to submit their email address. Although the the user is able to opt out of using product A, if they choose to, but they will still receive emails from the Company. If they choose option 2 they will be unsubscribed from all products the company provides.

here is my html:

<p class="text">Unsubscribe</p>

<p>I no longer wish to receive:</p> 
<form> 
     <input type="radio" name="choice1" value="choice1" />Information related to product A <br /> 
     <input type="radio" name="choice2" value="choice2" />Information about any product from Company A<br /> 
     <input type="button" value="submit" />
</form>

I have not moved on to the JS. I'm stuck in regards to the best approach. Any suggestions would be greatly appreciated. Thanks

Udit Bhardwaj
  • 1,761
  • 1
  • 19
  • 29

1 Answers1

0

give id to your form for example unscfrm then you can access the choice of user like in this example below

$('#unscfrm input[type=button]').click(function(event)

  {
    event.preventDefault();

    var choice=$('unscfrm').find('input:radio:checked').val();

    alert(choice);
  })
Udit Bhardwaj
  • 1,761
  • 1
  • 19
  • 29
  • Thank you very much for your input. Pleas note a field for the user's email address is not provided in the design. Will I need the user's email address, or is there a way I can access it via the browser? Basically what I'm saying is: When the user visits the unsubscribe page, via a link they click in the html email provided, can I access their info using ajax? Thanks again in advance. – Errol Coombs Oct 27 '13 at 14:50
  • @ErrolCoombs yes you can for example if it's a login based system user's login detail like email/user-id through which he/she has logged in can be stored in client/server side cookie or you can create a session and store the information their using server side scripting and at the time user select the unsubscribe option you can retrieve that info either from cookie or session data. **Note** if it's stored in session array or server side cookie you have to use ajax (in case you want request to be asynchronous) – Udit Bhardwaj Oct 27 '13 at 15:12