forms - Passing a specific value for a hidden field using javascript -
i working on email preference center , user has 4 options - 3 options email frequency , last option unsubscribe. have 2 different fields form passing - email frequency , email status. i'm having trouble email status field.
for radio buttons 1-3 want post email status ="i" , email frequency either "all", "weekly" or "monthly"
for last radio button want post email status = "o"
i can't seem both work - either passes , unsub radio button doesn't work or email status post o unsub null values buttons 1-3.
below base code i'm working with.
<input type="radio" name="email_frequency_status" value="w" id="email_frequency_status" >weekly <input type="radio" name="email_frequency_status" value="m" id="email_frequency_status"> monthly <input type="radio" name="email_frequency_status" value="a" id="email_frequency_status"> <input type="radio" name="email_status" value="o" id="email_status"> unsubscribe! <input name="update" type="image" value="send" src="update_btn.jpg" alt="update" >
i've tried using different javascript functions can't work desired. awesome!
update 7/11:
here's 1 variation of code tried...
<input type="radio" name="email_weekly" value="w" id="email_weekly" onclick="document.getelementbyid('email_status').value=i"/>send me 1 email per week <input type="radio" name="email_monthly" value="m" id="email_monthly" onclick="document.getelementbyid('email_status').value=i"/> send me 1 email per month. <input type="radio" name="email_all" value="a" id="email_all" onclick="document.getelementbyid('email_status').value=i"/> send me news, sales & offers. <input type="radio" name="email_status" value="o" id="email_status" onclick="document.getelementbyid('email_status').value=o"/>unsubscribe me emails. <input name="update" type="image" value="send" src="update_btn.jpg" alt="update" > <input type="hidden" name="email_status" value="" id="email_status" />
<script> function update_permission(perm) { document.getelementbyid('email_permission_status').value = perm; } </script> <form ...> <input type="radio" name="email_frequency_status" value="w" onclick="update_permission('i')"/>send me 1 email per week <input type="radio" name="email_frequency_status" value="m" onclick="update_permission('i')"/> send me 1 email per month. <input type="radio" name="email_frequency_status" value="a" onclick="update_permission('i')"/> send me news, sales & offers. <input type="radio" name="email_frequency_status" value="o" onclick="update_permission('o')"/>unsubscribe me emails. <input name="update" type="image" value="send" src="update_btn.jpg" alt="update" > <input type="hidden" name="email_permission_status" value="" id="email_permission_status" /> </form>
i got rid of id
attributes of radio buttons; duplicates , not needed. gave them same name -- when unsubscribe, there's no frequency, should uncheck frequency. radio button 1 choice doesn't make sense; if don't want part of group, should checkbox, not radio button.
personally, don't see point of hidden field. couldn't same thing in server code?
Comments
Post a Comment