I want to retrieve and display the value I entered

Asked 2 years ago, Updated 2 years ago, 75 views

<textarea name="id="content" cols="30" rows="10" placeholder="test">/textarea>   
 <input type="text" name="id="name" cols="30" rows="10" placeholder="name">

I am thinking of retrieving the information I entered from two areas, as shown above.

For Js,

//3. Get messages from the "message" datastore
        ds.stream().sort("desc").next(function(err,datas){
            data.forEach(function(data){
                renderMessage (data);
            });
        });

        // 4. Monitor "message" datastore push events
        ds.on("push", function(e){
            renderMessage(e);
        });

        var last_message="dummy";

        function renderMessage(message){
            var message_html='<p class="post-text">'+escapeHTML(message.value.content)+'</p>';
            vardate_html=';
            if(message.value.date){
                date_html='<p class="post-date">'+escapeHTML(newDate(message.value.date).toLocaleString())+'</p>';
            }
            $("#"+last_message).before('<div id="'+message.id+'" class="post">'+message_html+date_html+'</div>');
            last_message=message.id;
        }
function post(){
            // 5. Push a message to the "message" datastore
            var content=escapeHTML($("#content").val());
            var name =escapeHTML($("#name").val());
            if(content&&content!==""){
                US>ds.push({
                    title: "Title",
                    content:content,
                    name —name,
                    date —new Date().getTime()
                }, function(e){});
            }
            $("#content").val("";
            $("#name").val("";
        }

        $('#post').click(function(){
            console.log(name);
            post();
        })
        $('#content').keydown(function(e){
            if(e.which==13){
                post();
                return false;
            }
        });
        $("#name").keydown(function(e){
            if(e.which==13){
                post();
                return false;
            }
        });
    });`

Here's how it looks.

When the post is clicked, the content is displayed, but the name is not displayed.
I don't know how content is being retrieved from the datastore, but
How should I write the name?

Please.

javascript milkcocoa

2022-09-30 17:28

1 Answers

Maybe it's because it's not displayed.
I can't find the part where message.value.name is printed in renderMessage()...


2022-09-30 17:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.