I’m almost 90% sure its down to the way that i’m calling myData.dateDay in the email as i’m using my value myData.dateDay in other areas of my app and it is setting and getting fine. But this is the code for both…
[lua]
–my global space
local myData = {}
–Incident Reporting
–P2
myData.dateDay = “00”
myData.dateMonth = “00”
myData.dateYear = “00”
myData.timeHour = “00”
myData.timeMinute = “00”
myData.IRb1 = “N/A”
–P3
myData.incidentLocation = “N/A”
myData.IRb2 = “N/A”
–P4
myData.IRb3 = “N/A”
–P5
myData.injuryOccurred = “N/A”
–P6
myData.IRb4 = “N/A”
myData.openedOther = false
myData.openedHeight = false
–PH
myData.fallHeight = “N/A”
–PO
myData.textOther = “N/A”
–P7
myData.breifDes = “N/A”
–P8
myData.IRb5 = “N/A”
–P9
myData.IRb6 = “N/A”
–P10
myData.actionTaken = “N/A”
–P11
myData.nameAffected = “N/A”
myData.affectedEmail = “N/A”
myData.affectedPhone = “N/A”
–P12
myData.studentSchool = “N/A”
myData.staffDepartment = “N/A”
myData.lineManagersName = “N/A”
–P13
myData.witnessName = “N/A”
myData.witnessEmail = “N/A”
myData.witnessPhone = “N/A”
–P14
myData.witnessStudentSchool = “N/A”
myData.witnessStaffDepartment = “N/A”
–P15
myData.reportingName = “N/A”
myData.reportingEmail = “N/A”
myData.reportingPhone = “N/A”
–P16
myData.reportingStudentSchool = “N/A”
myData.reportingStaffDepartment = “N/A”
–Risk Assessment
myData.risk1 = “N/A”
return myData
[/lua]
[lua]
–
– incidentReportingPg2.lua
–
local composer = require( “composer” )
local scene = composer.newScene()
local widget = require( “widget” )
local myData = require( “myData” )
local function btnPrevious( event )
composer.gotoScene( “incidentReportingPg1”, { effect=“slideRight”, time=800} )
end
function scene:create( event )
local sceneGroup = self.view
local function textListener( event )
local target = event.target
local maxLen = target.maxLen
local text = event.text
if ( event.phase == “began” ) then
print( text )
else
if( text and string.len( text ) > maxLen ) then – aborts early if text is nil
target.text = string.sub( text, 1, maxLen )
end
end
end
–bg
local bg = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bg.anchorX = 0
bg.anchorY = 0
bg:setFillColor( 0.9, 0.9, 0.9 ) – white
sceneGroup:insert( bg )
–titleHeader
local titleHeader = display.newImage( “titleHeader.png” )
titleHeader:translate( 160, -22 )
–title
local title = display.newText( “Incident Reporting”, 0, 0, native.systemFont, 32 )
title:setFillColor( 0 ) – black
title.x = display.contentWidth * 0.5
title.y = -25
–textPage
local textPage = display.newText(“Page 2”,
280,130, display.contentWidth -25 , display.contentHeight * 0.5, native.systemFont, 15 )
textPage:setFillColor( 0, 0, 0 )
–textSectionA
local textSectionA = display.newText(“Section A: About the Incident”,
172, 155, display.contentWidth, display.contentHeight * 0.5, native.systemFont, 20 )
textSectionA:setFillColor( 0, 0, 0 )
sceneGroup:insert( textSectionA )
–textDate
local textDate = display.newText(“Incident Date: (DD/MM/YY)”,
175, 190, display.contentWidth, display.contentHeight * 0.5, native.systemFont, 13 )
textDate:setFillColor( 0, 0, 0 )
sceneGroup:insert( textDate )
–textBoxDay
local textBoxDay = native.newTextField( 54, 110, 75, 40 )
textBoxDay.size = 20
textBoxDay:addEventListener( “userInput”, textListener )
textBoxDay.inputType = “number”
textBoxDay.maxLen = 2
sceneGroup:insert( textBoxDay )
–forwardSlash
local forwardSlash = display.newImage( “forwardSlash.png” )
forwardSlash:translate( 105, 110 )
sceneGroup:insert( forwardSlash )
–textBoxMonth
local textBoxMonth = native.newTextField( 156, 110, 75, 40 )
textBoxMonth.size = 20
textBoxMonth:addEventListener( “userInput”, textListener )
textBoxMonth.inputType = “number”
textBoxMonth.maxLen = 2
sceneGroup:insert( textBoxMonth )
–forwardSlash
local forwardSlash = display.newImage( “forwardSlash.png” )
forwardSlash:translate( 207, 110 )
sceneGroup:insert( forwardSlash )
–textBoxYear
local textBoxYear = native.newTextField( 258, 110, 75, 40 )
textBoxYear.size = 20
textBoxYear:addEventListener( “userInput”, textListener )
textBoxYear.inputType = “number”
textBoxYear.maxLen = 2
sceneGroup:insert( textBoxYear )
–textTime
local textTime = display.newText(“Incident Time: (HH:MM)”,
175, 270, display.contentWidth, display.contentHeight * 0.5, native.systemFont, 13 )
textTime:setFillColor( 0, 0, 0 )
sceneGroup:insert( textTime )
–textBoxHour
local textBoxHour = native.newTextField( 54, 190, 75, 40 )
textBoxHour.size = 20
textBoxHour:addEventListener( “userInput”, textListener )
textBoxHour.inputType = “number”
textBoxHour.maxLen = 2
sceneGroup:insert( textBoxHour )
–semiColon
local semiColon = display.newImage( “semiColon.png” )
semiColon:translate( 105, 190 )
sceneGroup:insert( semiColon )
–textBoxMinute
local textBoxMinute = native.newTextField( 156, 190, 75, 40 )
textBoxMinute.size = 20
textBoxMinute:addEventListener( “userInput”, textListener )
textBoxMinute.inputType = “number”
textBoxMinute.maxLen = 2
sceneGroup:insert( textBoxMinute )
–Divider
local divider = display.newImage( “titleHeader.png” )
divider:translate( 160, 240 )
sceneGroup:insert( divider )
–textWasThis
local textWasThis = display.newText(“Was this an incident that caused harm?”,
212, 422, display.contentWidth, display.contentHeight * 0.5, native.systemFont, 13 )
textWasThis:setFillColor( 0, 0, 0 )
sceneGroup:insert( textWasThis )
–textEgPer
local textEgPer = display.newText(“eg personal harm or damage to property”,
212, 437, display.contentWidth, display.contentHeight * 0.5, native.systemFont, 11 )
textEgPer:setFillColor( 0, 0, 0 )
sceneGroup:insert( textEgPer )
–textWasThisA
local textWasThisA = display.newText(“Was this a Near Miss (No Harm)?”,
212, 480, display.contentWidth, display.contentHeight * 0.5, native.systemFont, 13 )
textWasThisA:setFillColor( 0, 0, 0 )
sceneGroup:insert( textWasThisA )
– Image sheet options and declaration
local options = {
width = 26,
height = 26,
numFrames = 2,
sheetContentWidth = 26,
sheetContentHeight = 52
}
local checkboxSheet = graphics.newImageSheet( “checkboxSheet.png”, options )
– Create a group for the radio button set
local radioGroup = display.newGroup()
– Create two associated radio buttons (inserted into the same display group)
local radioButton1 = widget.newSwitch
{
left = 20,
top = 300,
style = “radio”,
id = “RadioButton1”,
width = 26,
height = 26,
onPress = onSwitchPress,
sheet = checkboxSheet,
frameOff = 1,
frameOn = 2
}
radioGroup:insert( radioButton1 )
sceneGroup:insert( radioButton1 )
local radioButton2 = widget.newSwitch
{
left = 20,
top = 353,
style = “radio”,
id = “RadioButton2”,
width = 26,
height = 26,
onPress = onSwitchPress,
sheet = checkboxSheet,
frameOff = 1,
frameOn = 2
}
radioGroup:insert( radioButton2 )
sceneGroup:insert( radioButton2 )
local function OnbtnNext( event )
if event.phase == “ended” then
local radioOn = false
local textFilled = true
myData.dateDay = textBoxDay.text
myData.dateMonth = textBoxMonth.text
myData.dateYear = textBoxYear.text
myData.timeHour = textBoxHour.text
myData.timeMinute = textBoxMinute.text
if radioButton1.isOn == true then
myData.IRb1 = “Yes”
radioOn = true
end
if radioButton2.isOn == true then
myData.IRb1 = “No (Near Miss)”
radioOn = true
end
if textBoxDay.text == “” or textBoxDay.text == nil or
textBoxMonth.text == “” or textBoxMonth.text == nil or
textBoxYear.text == “” or textBoxYear.text == nil or
textBoxHour.text == “” or textBoxHour.text == nil or
textBoxMinute.text == “” or textBoxMinute.text == nil then
textFilled = false
end
if radioOn and textFilled then
composer.gotoScene( “incidentReportingPg3”, { effect=“slideLeft”, time=800,} )
else
local msg
if radioOn == false and textFilled == false then
msg = “No input in checkbox(s) and textbox(s)”
else
if radioOn then
msg = “No input in textbox(s)”
else
msg = “No input in checkbox(s)”
end
end
local alert = native.showAlert( “Warning”, "ERROR: "…msg, { “OK” }, onComplete)
end
end
return true
end
–btnPrevious
local btnPrevious = widget.newButton
{
width = 150,
height = 40,
defaultFile = “btnPrevious.png”,
onEvent = btnPrevious
}
btnPrevious.x = 84
btnPrevious.y = 445
–btnNext
local btnNext = widget.newButton
{
width = 150,
height = 40,
defaultFile = “btnNext.png”,
onEvent = OnbtnNext
}
btnNext.x = 235
btnNext.y = 445
–sceneGroup
sceneGroup:insert( titleHeader )
sceneGroup:insert( title )
sceneGroup:insert( textPage )
sceneGroup:insert( btnNext )
sceneGroup:insert( btnPrevious )
end
function scene:show( event )
local sceneGroup = self.view
end
function scene:hide( event )
local sceneGroup = self.view
end
function scene:destroy( event )
local sceneGroup = self.view
end
– Listener setup
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )
return scene
[/lua]