0

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?

0

3 Answers 3

1

Since you are trying to pass a string You have to do like below

<div id="order" onclick="GetOrder('test 1')">click me!</div>
Sign up to request clarification or add additional context in comments.

Comments

1

Try using

<div id="order" onclick="GetOrder('test 1')">click me!</div>

Comments

0

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>

2 Comments

please check the question again
@lails, did you tried jquery way. Just pass value using cutom attributes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.