I want to get 'id'
from url and using in my Bootstrap modal.
How to get this '69'
.In my modal i using this '69'
with SQL request.
Asked
Active
Viewed 3,543 times
-2

rrk
- 15,677
- 4
- 29
- 45

Стилиян Георгиев
- 29
- 1
- 8
-
4possible duplicate of [How can I get query string values in JavaScript?](http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript) – Amit Joki Sep 21 '15 at 15:15
-
http://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-url-parameter – ka_lin Sep 21 '15 at 15:15
-
If you can, it's better to render a JavaScript variable, which will hold that ID, server-side. URL parsing will depend on URL format, so if you change it in a future, it can break your parsing. – David Ferenczy Rogožan Sep 21 '15 at 15:35
2 Answers
2
I Hope, your JS code is somehow similar to it.
<script>
$('.Contact').click(function(){
var id=$('.Contact').val();
$.ajax({url:"ModalPage.php?id="+id,cache:false,success:function(result){
$(".modal-content").html(result);
}});
});
</script>
In, ModalPage.php
<?
$id=$_GET['id'];
// Now, use this 'id'.
?>

DirtyBit
- 16,613
- 4
- 34
- 55

Nana Partykar
- 10,556
- 10
- 48
- 77
-
1No Man. I'm Delighted That This Answer Is Now Having Right Syntax. Thanku For Making Correction @HawasKaPujaari. I always have respect for you. Thanku for giving so much time to stack. – Nana Partykar Sep 28 '15 at 17:41
-
1
1
an easy trick is to make hidden input inside modal code as below
<div id="myModal">
<form>
<input type="hidden" value="<?php echo isset($_GET['id']?$_GET['id']:''); ?>" /> <!--if you want to make it hidden-->
<label>ID = <?php echo isset($_GET['id']?$_GET['id']:''); ?></label><!--if you want to display-->
<!--your code-->
</form>
</div>

alamnaryab
- 1,480
- 3
- 19
- 31