Hi everyone,
I'm trying to add some functionality into an iPad app that will use a user input value in a simple math equation. Currently, in a View, I have a product image, description and price. The code looks like this (The last section, var text, is probably the most important section if you want to skip down)
var product1 = Titanium.UI.createView({ backgroundColor:'#b7b7b7', borderRadius:3, width:748, height:183, top:10, left:10 }); productScrollView.add(product1); var productImageView1 = Titanium.UI.createImageView({ image:'products/product1.jpg', borderRadius:3, width:370, height:163, top:10, left:10 }); product1.add(productImageView1); var product1TextBox = Titanium.UI.createScrollView({ backgroundColor:'#ffffff', contentWidth:290, contentHeight:'auto', borderRadius:3, width:300, height:163, top:10, right:58 }); product1.add(product1TextBox); var text = Ti.UI.createLabel({ text:'PRODUCT TITLE\n\n$99\n\nProduct description.\n\nInstallation Charges Extra', color:'#000000', width:'auto', height:'auto', top:5, left:5, font:{fontSize:14,fontFamily:'Helvetica Neue'} }); product1TextBox.add(text);I want individual franchises to be able to input their shop rate, then make an equation that would be:
Shop Rate x Installation Time + Product Price (in this case $99)
I have an area where the user inputs their shop rate using this code
var shopRateTextField = Titanium.UI.createTextField({ //hintText:'User name here...', height:'auto', width:'30%', top:60, textAlign:'left', borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED, keyboardType:Titanium.UI.KEYBOARD_NUMBER_PAD, returnKeyType:Titanium.UI.RETURNKEY_NEXT }); var calculatePrices = Titanium.UI.createButton({ title:'Calculate', width:'30%', height:'auto', top:90 }); calculatePrices.addEventListener("click",function(eventObject){ alert(shopRateTextField.value); });Does anyone know how I can make the equation above and have the result show up in a label? Specifically in var text where the $99 currently is.
I've been going at this for a week and a half and don't have much to show for it. Any help would be greatly appreciated.