Cyber
Cyber

Reputation: 5000

Access Dojox.mobile.TextBox value from .js Function?

I am developing a Hybrid application in IBM Worklight .Since i am a newbie in Worklight and Dojo its just a sample application that takes text input value and displays in Alert.I have created a text box, but cant access text box value from javascript function.

My code

<input data-dojo-type="dojox.mobile.TextBox" id="sampleText" placeHolder="NewYork,USA">
<button data-dojo-type="dojox.mobile.Button" id=testBtn style="float:right;" data-dojo-props="label:'GetData', onClick:function(e){getDataInfo();}" ></button>

js Function

function getDataInfo(){
    var city = dojox.byId("sampleText").value;
    alert(city);

}

Any help is appreciated.

Upvotes: 0

Views: 580

Answers (1)

Angelo
Angelo

Reputation: 814

There are 2 solution. Edit the function:

function getDataInfo(){
    var city = sampleText.value;
    alert(city);
}

or add dojo-id to textBox

data-dojo-props='id:"sampleText"'>

and use this function

dojox.byId("sampleText")

Upvotes: 2

Related Questions