“nilainya documentscript.getElementById nilai” Kode Jawaban

Nilai properti tidak ada pada jenis htmlelement.

document.getElementById() returns the type HTMLElement which does not contain a value property.
The subtype HTMLInputElement does however contain the value property.

So a solution is to cast the result of getElementById() to HTMLInputElement like this:

var inputValue = (<HTMLInputElement>document.getElementById(elementId)).value;
<> is the casting operator in typescript.
See TypeScript: casting HTMLElement: https://fireflysemantics.medium.com/casting-htmlelement-to-htmltextareaelement-in-typescript-f047cde4b4c3

The resulting javascript from the line above looks like this:

inputValue = (document.getElementById(elementId)).value;
i.e. containing no type information.
Vivacious Vendace

nilainya documentscript.getElementById nilai

<script>
function gotowhatsapp() {
    
    var name = document.getElementById("name").value;
    var email = document.getElementById("email").value;
	var phone = document.getElementById("phone").value;
	var whats = document.getElementById("whats").value;
    var service = document.getElementById("service").value;

    var url = "https://wa.me/919843341999?text=" 
    + "Name: " + name + "%0a"
    + "Email: " + email  + "%0a"
	+ "Phone: " + phone + "%0a"
	+ "whats: " + whats + "%0a"
    + "Service: " + service; 

    window.open(url, '_blank').focus();
}
</script>
Ugly Unicorn

Jawaban yang mirip dengan “nilainya documentscript.getElementById nilai”

Pertanyaan yang mirip dengan “nilainya documentscript.getElementById nilai”

Lebih banyak jawaban terkait untuk “nilainya documentscript.getElementById nilai” di TypeScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya