Reputation: 105
my uploaded JQ scripts
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.1.1.js"></script>
and my php code
echo '<div id="zakazat" onclick="GetOrder('.$row['title'].')">Заказать!</div>';
title have is string value : "test 1"
my simple js code
function GetOrder(param1){
alert(param1);
};
In the my function have error in FireBug with text: " SyntaxError: missing ) after argument list GetOrder(test 1)"
hov fix task?
Upvotes: 0
Views: 83
Reputation: 133403
As you are using jQuery. You can try this.
Store your data in custom data-*
prefixed attributes
<div id="order" data-param="test 1">click me!</div>
Bind click event like
$("#order").on('click', function(){
var param1 = $(this).data('param'); //Fetch data using .data()
GetOrder(param1);
});
You have to pass string parameter in quotes ''
<div id="order" onclick="GetOrder('test 1')">click me!</div>
Upvotes: 0
Reputation: 1779
Try using
<div id="order" onclick="GetOrder('test 1')">click me!</div>
Upvotes: 1
Reputation: 6344
Since you are trying to pass a string You have to do like below
<div id="order" onclick="GetOrder('test 1')">click me!</div>
Upvotes: 1