Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  16] [ 4]  / answers: 1 / hits: 16808  / 10 Years ago, fri, february 28, 2014, 12:00:00

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



I want the following behaviour:



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


I want to output with alert 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>

More From » javascript

 Answers
16

use this code:



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

[#72244] Thursday, February 27, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yosefleod

Total Points: 113
Total Questions: 100
Total Answers: 115

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
;