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.

有帮助吗?

解决方案

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")
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top