0

I need some advice,

I have a simple html input type text field:

<p><input id="mrmid" type="text" name="mrmid" size="30" /></p>

I am trying to get his values using a submit function, like this:

$("#myform").submit(function(){
    var mrmid = $("#mrmid").val();
    alert("mrmid");
});

Instead of the submitted value, lets say I submit "123", the alert alertss "mrmid" (the input name).

Why is this happening?

Is this the way to go, or should I use the serializeArray() method? Which I know it works and I saw it documented on stack.

Ty

1
  • It's not printing the input name, it's printing your string: "mrmid" is a string literal. You want the variable: mrmid (no quotes) Commented Feb 7, 2013 at 15:55

3 Answers 3

2

I think you have to use alert(mrmid); instead of alert("mrmid");

Sign up to request clarification or add additional context in comments.

Comments

0

You are alerting string "mrmid" instead of variable mrmid.

Change

alert("mrmid");

to

alert(mrmid);

Comments

0

Because you are alerting a string "mrmid", not the value in mrmid variable. Remove double quotes for mrmid in alert

$("#eloqua").submit(function(){
    var mrmid = $("#mrmid").val();
    alert(mrmid);
});

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.