1

I am trying to create a new jQuery variable from some text and another jQuery variable.

This is what I have tried but it just displays "+emc+" instead of the value that the variable is set to.

var emc = $(".emc").attr("value");
var new_page = "index.php?emc=+emc+";

The new_page variable should display index.php?emc=XXXXXX but instead it displays as index.php?emc=+emc+

2
  • 1
    Side note - you're creating a JavaScript variable, not a jQuery variable. Commented Jun 25, 2013 at 16:11
  • why is there jquery-mobile tag? Commented Jun 25, 2013 at 16:19

3 Answers 3

4

If I've understood correctly:

var new_page = "index.php?emc="+emc;

Or, indeed:

var new_page = "index.php?emc="+$(".emc").val();
Sign up to request clarification or add additional context in comments.

Comments

3

You made a mistake in your string concatenation. You wanted to do this:

var new_page = "index.php?emc="+emc;

Comments

2

You have included the variable in the constant your code must look like:

var emc = $(".emc").attr("value");
var new_page = "index.php?emc="+emc;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.