0

I was previously helped to get a javscript function using jquery working - see : JS Fiddle working example

$("[name='COLUMN35']").on('change', function() {
  var val = $(this).val();
  var reverseVal = (val == 'Yes' ? 'No' : 'Yes')
  $("input[value='" + reverseVal + "']:not([name='COLUMN35'])").prop('checked', true);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>Option 1</span><br />
<form>
<label><input type="radio" name="option1" id="option1Yes" value="Yes">Yes</label>
<label><input type="radio" name="option1" id="option1No" value="No">No</label>
<br /><br />
<span>Option 2</span><br />
<label><input type="radio" name="option2" id="option2Yes" value="Yes">Yes
</label>
<label><input type="radio" name="option2" id="option2No" value="No">No</label>
<hr />
<span>Unsubscribe from all</span><br />
<label><input type="radio" name="COLUMN35" id="unsubYes" value="Yes">Yes</label>
<label><input type="radio" name="COLUMN35" id="unsubNo" value="No">No</label>
<br /><br />
<input type="submit" value="submit">
</form>

Upon implmenting that same code into the generated form page i am not sure why it does not work - see: Webform with code not working

Unfortunately I am not able to edit the any of the form elements as they are generated automatically but hoping someone might have a different idea to implement - usually the messier the better E.G target the relevant ids to change and maybe not using jquery

1 Answer 1

1

try putting your code in $(document).ready(function(){}) eg

$(document).ready(function(){
$("[name='COLUMN35']").on('change', function(){
    var val = $(this).val();
    var reverseVal = (val == 'Yes' ? 'No' : 'Yes')
    $("input[value='"+reverseVal+"']:not([name='COLUMN35'])").prop('checked', true);
});
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.