Reputation: 65
I have a very interesting scenario How can accept value like this in jquery
System.out.println("Hello world");
Right now jquery only accept value till first double quote
System.out.println(
I am getting this value using
var useranswer = $("input[name='radgroup1;?>']:checked").val();
<input type="radio" name="radgroup1>"
value="System.out.println("Hello world")">System.out.println("Hello world")</label>
Thanks for your help fairly new to jquery
Upvotes: 0
Views: 58
Reputation: 2666
I have created a sample code for your requirement, Please check If it helps you?
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<input name="radgroup1" type="checkbox" value='System.out.println("Hello world")' checked="checked" />
<input name="radgroup2" type="checkbox" value="22" />
<?php $question = 1; ?>
<script>
jQuery( document ).ready(function($){
var useranswer = $("input[name='radgroup<?php echo $question;?>']:checked").val();
alert(useranswer);
});
</script>
Feel free to know your doubts
Upvotes: 1
Reputation: 214
try this:
use console.log(useranswer);
and press f12 key to view your answer
Upvotes: 1