0

everything working as my desire but when I click on book room button it can not generate input field for me but its shows as [object HTMLFormElement] here is my code

function booking(roomBooking){  
    var f = document.createElement("form");
    var in1 = document.createElement("input");
    in1.type = "text";
    in1.name = "user_name";
    in1.id = "user_name1";
    f.appendChild(in1);
    document.getElementById("name").innerHTML=f;    
}

I want to show form when I clicked on book room button.

1 Answer 1

1

Here you are:

You should just apply your f variable to "#name" element by using appendChild() function, because "f" it's an object and you cannot directly use it.

function booking(roomBooking) {
    var f = document.createElement("form");
    var in1 = document.createElement("input");

    in1.type = "text";
    in1.name = "user_name";
    in1.id = "user_name1";
    f.appendChild(in1);

    document.getElementById("name").appendChild(f);    
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.