How to get url value after question mark in javascript

How can I get url value after question mark in javascript?

I need the following behavior:

if value is yes then 10+2 
else if value is no then 10.

I want to display warning messages.

<div class="col-xs-4 col-sm-4 col-md-4 text-center width100">
    <a href="piccal.html" class="btn btn-success" id="yes">PIC Grant Calculator</a>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 text-center width100">
    <a href="piccal.html" class="btn btn-danger" id="no">PIC Grant Calculator</a>
</div>

<script> 
if (value == no) {
    alert('hello');
}
</script>

<script> 
if (value == yes) {
    alert('hi');
}
</script>
+4
source share
2 answers

use this code:

var a = location.href; 
var b = a.substring(a.indexOf("?")+1);
+7
source

use javsacript and type:

location.search
+5
source

Source: https://habr.com/ru/post/1529398/


All Articles