I tried writing this code for text input

I hope someone can help me! If you can run this and tell me why it is only FULLY WORKING for first Field.

supportedOrientations(LANDSCAPE_ANY) 


function setup()
    Fields = {"Patient's Name:","Date Of Birth:","Sexe:","School/Rehabilitation Center:","Grade:","Examiner's eMail:"}
     inp = 0
     str = ""
     input={}
     y = 0
    
end

function draw()
    pushStyle()
    background(255,255,255,255)
    fill(0,0,0,255)
    textAlign(LEFT)
    fontSize(22)
    font("TimesNewRomanPSMT")
    text("Patient's ID",WIDTH/3,HEIGHT-50)
    for i = 1,6 do
    text(Fields[i],200,HEIGHT-(i*100))     
    end
    for i = 1,6 do
        noFill()
        strokeWidth(2)
        stroke(0, 0, 0, 255)
        rect(400,HEIGHT-(i*100)-75/2,500,50)    
    end
    fill(255, 255, 255, 255)
    for i = 1,6 do  
    rect(400,HEIGHT-(i*100)-75/2,500,50)
    end
    fill(0, 0, 0, 255)   
    if keyboardBuffer() ~= nil then
        text(keyboardBuffer(),650,y+25)  
        else 
        text(str,650,y+25)
    end
    
    if input[1] ~= nil then text(input[1],650,HEIGHT-275/2 + 15) else
    if input[2] ~= nil then text(input[2],650,HEIGHT-475/2 + 15) else
    if input[3] ~= nil then text(input[3],650,HEIGHT-675/2 + 15) else
    if input[4] ~= nil then text(input[4],650,HEIGHT-875/2 + 15) else
    if input[5] ~= nil then text(input[5],650,HEIGHT-1075/2 + 15) else
    if input[6] ~= nil then text(input[6],650,HEIGHT-1275/2 + 15) else  
    end end end end end end
    
    popStyle() 
end

function touched(tch)     
     local currentTouchPosition = vec2 (tch.x,tch.y)
        if currentTouchPosition.y< HEIGHT- 275/2 + 50 and currentTouchPosition.y > HEIGHT- 275/2 then inp = 1
    
        else if currentTouchPosition.y < HEIGHT- 475/2 + 50 and tch.y > HEIGHT- 475/2 then inp = 2
            else if currentTouchPosition.y < HEIGHT- 675/2 + 50 and currentTouchPosition.y > HEIGHT- 675/2 then inp = 3
                else if currentTouchPosition.y < HEIGHT- 875/2 + 50 and currentTouchPosition.y > HEIGHT- 875/2 then inp = 4
                    else if currentTouchPosition.y < HEIGHT- 1075/2 + 50 and currentTouchPosition.y > HEIGHT- 1075/2 then inp = 5
                        else if currentTouchPosition.y < HEIGHT- 1275/2 + 50 and currentTouchPosition.y > HEIGHT- 1275/2 then inp = 6
                    end
                end
            end
        end
    end
    end  
    local l = 400
    local r = 900  
    local b = HEIGHT-(inp*100)-75/2
    local t = HEIGHT-(inp*100)-75/2 + 50
    if currentTouchPosition.x > l and currentTouchPosition.x < r then
        if currentTouchPosition.y > b and currentTouchPosition.y < t then
            showKeyboard()
            y = HEIGHT - (inp*100)- 75/2
        end
    end 
end

function keyboard(key) -- move keyboardBuffer to str when return is pressed
    if key == RETURN then
        str = keyboardBuffer()
        input[inp] = str
        hideKeyboard()
    end
end

@dave1707 i used one of the codes you sent me! And started from there but i got stock. If you can tell me where the mistake is

i’ve edited your post so the code looks correct.
please put 3 ~ before and after to get the correct rendering above.
thanks

@jmv38 what ? Should i post it again with ~~~ in the beginning and end?

Use elseif (no space) and a single end call, don’t nest loads of else if calls.

@yojimbo2000 i tried it, i got the same result only the text in first blankfiel is staying on screen other fiels are dissapering when pressing return.

supportedOrientations(LANDSCAPE_ANY) 


function setup()
    Fields = {"Patient's Name:","Date Of Birth:","Sexe:","School/Rehabilitation Center:","Grade:","Examiner's eMail:"}
     inp = 0
     str = ""
     input={}
     y = 0
    
end

function draw()
    pushStyle()
    background(255,255,255,255)
    fill(0,0,0,255)
    textAlign(LEFT)
    fontSize(22)
    font("TimesNewRomanPSMT")
    text("Patient's ID",WIDTH/3,HEIGHT-50)
    for i = 1,6 do
    text(Fields[i],200,HEIGHT-(i*100))     
    end
    for i = 1,6 do
        noFill()
        strokeWidth(2)
        stroke(0, 0, 0, 255)
        rect(400,HEIGHT-(i*100)-75/2,500,50)    
    end
    fill(255, 255, 255, 255)
    for i = 1,6 do  
    rect(400,HEIGHT-(i*100)-75/2,500,50)
    end
    fill(0, 0, 0, 255)   
    if keyboardBuffer() ~= nil then
        text(keyboardBuffer(),650,y+25)  
        else 
        text(str,650,y+25)
    end
    
    if input[1] ~= nil then text(input[1],650,HEIGHT-275/2 + 15) elseif 
        input[2] ~= nil then text(input[2],650,HEIGHT-475/2 + 15) elseif 
        input[3] ~= nil then text(input[3],650,HEIGHT-675/2 + 15) elseif 
        input[4] ~= nil then text(input[4],650,HEIGHT-875/2 + 15) elseif 
        input[5] ~= nil then text(input[5],650,HEIGHT-1075/2 + 15) elseif 
        input[6] ~= nil then text(input[6],650,HEIGHT-1275/2 + 15) else  
     end
    
    popStyle() 
end

function touched(tch)     
     local currentTouchPosition = vec2 (tch.x,tch.y)
        if currentTouchPosition.y< HEIGHT- 275/2 + 50 and currentTouchPosition.y > HEIGHT- 275/2 then inp = 1
        elseif currentTouchPosition.y < HEIGHT- 475/2 + 50 and tch.y > HEIGHT- 475/2 then inp = 2
        elseif currentTouchPosition.y < HEIGHT- 675/2 + 50 and currentTouchPosition.y > HEIGHT- 675/2 then inp = 3
        elseif currentTouchPosition.y < HEIGHT- 875/2 + 50 and currentTouchPosition.y > HEIGHT- 875/2 then inp = 4
        elseif currentTouchPosition.y < HEIGHT- 1075/2 + 50 and currentTouchPosition.y > HEIGHT- 1075/2 then inp = 5
        elseif currentTouchPosition.y < HEIGHT- 1275/2 + 50 and currentTouchPosition.y > HEIGHT- 1275/2 then inp = 6
        end  
    local l = 400
    local r = 900  
    local b = HEIGHT-(inp*100)-75/2
    local t = HEIGHT-(inp*100)-75/2 + 50
    if currentTouchPosition.x > l and currentTouchPosition.x < r then
        if currentTouchPosition.y > b and currentTouchPosition.y < t then
            showKeyboard()
            y = HEIGHT - (inp*100)- 75/2
        end
    end 
end

function keyboard(key) -- move keyboardBuffer to str when return is pressed
    if key == RETURN then
        str = keyboardBuffer()
        input[inp] = str
        hideKeyboard()
    end
end

Try this.

supportedOrientations(LANDSCAPE_ANY) 

function setup()
    Fields = {"Patient's Name:","Date Of Birth:","Sexe:","School/Rehabilitation Center:","Grade:","Examiner's eMail:"}
     inp = 0
     str = ""
     input={}
     y = 0
end

function draw()
    pushStyle()
    background(255,255,255,255)
    fill(0,0,0,255)
    textAlign(LEFT)
    fontSize(22)
    font("TimesNewRomanPSMT")
    text("Patient's ID",WIDTH/3,HEIGHT-50)
    for i = 1,6 do
        text(Fields[i],200,HEIGHT-(i*100))     
    end
    for i = 1,6 do
        noFill()
        strokeWidth(2)
        stroke(0, 0, 0, 255)
        rect(400,HEIGHT-(i*100)-75/2,500,50)    
    end
    fill(255, 255, 255, 255)
    for i = 1,6 do  
        rect(400,HEIGHT-(i*100)-75/2,500,50)
    end
    fill(0, 0, 0, 255)   
    if keyboardBuffer() ~= nil then
        text(keyboardBuffer(),650,y+25)  
    else 
        text(str,650,y+25)
    end
    if input[1] ~= nil then text(input[1],650,HEIGHT-275/2 + 15) end
    if input[2] ~= nil then text(input[2],650,HEIGHT-475/2 + 15) end
    if input[3] ~= nil then text(input[3],650,HEIGHT-675/2 + 15) end
    if input[4] ~= nil then text(input[4],650,HEIGHT-875/2 + 15) end
    if input[5] ~= nil then text(input[5],650,HEIGHT-1075/2 + 15) end
    if input[6] ~= nil then text(input[6],650,HEIGHT-1275/2 + 15) end
    popStyle() 
end

function touched(tch)     
    local currentTouchPosition = vec2 (tch.x,tch.y)
    if currentTouchPosition.y< HEIGHT- 275/2 + 50 and 
            currentTouchPosition.y > HEIGHT- 275/2 then 
        inp = 1
    elseif currentTouchPosition.y < HEIGHT- 475/2 + 50 and 
            tch.y > HEIGHT- 475/2 then 
        inp = 2
    elseif currentTouchPosition.y < HEIGHT- 675/2 + 50 and 
                currentTouchPosition.y > HEIGHT- 675/2 then 
        inp = 3
    elseif currentTouchPosition.y < HEIGHT- 875/2 + 50 and 
                currentTouchPosition.y > HEIGHT- 875/2 then 
        inp = 4
    elseif currentTouchPosition.y < HEIGHT- 1075/2 + 50 and 
                currentTouchPosition.y > HEIGHT- 1075/2 then 
        inp = 5
    elseif currentTouchPosition.y < HEIGHT- 1275/2 + 50 and 
                currentTouchPosition.y > HEIGHT- 1275/2 then 
        inp = 6
    end
    local l = 400
    local r = 900  
    local b = HEIGHT-(inp*100)-75/2
    local t = HEIGHT-(inp*100)-75/2 + 50
    if currentTouchPosition.x > l and currentTouchPosition.x < r then
        if currentTouchPosition.y > b and currentTouchPosition.y < t then
            showKeyboard()
            y = HEIGHT - (inp*100)- 75/2
        end
    end 
end

function keyboard(key) -- move keyboardBuffer to str when return is pressed
    if key == RETURN then
        str = keyboardBuffer()
        input[inp] = str
        hideKeyboard()
    end
end

@dave1707 it is the same i posted earlier! What did you change to my secomd comment?

I just saw the end if! Let me check

@dave1707 thank you veryy much it workedddd . You made my dayyyy