简体   繁体   中英

How do I get the value of input fields and display it on the dialog box?

<dialog>

label id="show" label

label id="show1" label

</dialog>

var x = document.getElementById("name").value;
x = document.getElementById("show").innerHTML;

var y = document.getElementById("matrix").value;
y = document.getElementById("show1").innerHTML;

I used label form with only id="" and without for="" is it valid?

Also i'm trying to get the id(value) of the input and display it on the dialog box, is this the correct code to get it?

I used this code but failed to display the output on dialog box .. I'm still new in javascript

Please make your question more clear. Do you want to get text of label control?

If yes then you can use below jquery code :-

var x= $('#show').text();

var y= $('#show1').text();

Edited

Or if you want to show value of textbox into label of dialog than please try below code :-

var x= $("#textboxID").val()

And you can set this text to label:-

$("#LabelID").val(x);

A little bit change in your code is needed, problem in your code is you are not assigning your 'x' to any field

var x = document.getElementById("name").value;
document.getElementById("show").innerHTML = x;

Here is a jsFiddle, check out here.

jsFiddle

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM