HOME ➔ SUPPORT ➔ Community ➔ General CourseLab issues ... Extracting Values from Textbox
Extracting Values from Textbox
  View type:
I am facing difficulty in exctracting values from textbox. I have created a login form and want to display the name of user when he logs in.
I have used java script.
Following is the code that i m using.. and geting error in extracting value from textbox
run time name of textbox is OBJ_11.
code in java script:

var name;
name = document.getElementById("OBJ_11").value;

alert("test " +name+" hiiii")

kindly help me to get the solution for the above problem.

Hi, Anuya,

Actually, OBJ_11 is NOT the input field id - it is it's container id. There is much easier way to obtain this data - every input field object is associated with CourseLab run-time variable - when the value is inserted it is copied to this variable also. You can also use in expressions object's (i.e. CourseLab object's) "value" property (as $OBJ_11.value).

If you strictly need JavaScript, then you can use something like:

var aTags = document.getElementById("OBJ_11").getElementsByTagName("input");
var sName = aTags[0].value;
Message options
No additional options