Help me with my homework please

Anyone guys help me. How can I make like this?
VIDEO: https://www.youtube.com/watch?v=2-IVubSIV2E

Hi jgatanela02 welcome to the forum

Before getting into the JavaScript code needed to take form input values and have those values display in place of the inputs, what does the HTML look like?

3 Likes

Can u explain what you are trying to achieve ? Are you just trying to hide the input fields and display the text after you click on Test? It will be better if you posted your code because the YouTube video is not too clear either…

AJAX and jQuery. I just want to make like on the video to my homework. I’m Newbie at Javascript :frowning:

Why jQuery and Ajax? It looks like you can do this with vanilla JS.

In any case, as @Mittineague says, we need to see your HTML form to begin with…

This code given by my friend it doesn’t work and I don’t know how to fix it anyone guys please help me. I want to remove “url: "http://example.com/send" + "/" + address + "/" + amount,” to make it simple. When I’m clicking test button the content is not showing :frowning: . I’m newbie at coding guys please help me

<div id="start">
  <div class="class1">
  <label><h3>TEST</h3>
    <input type="text" name="wallet" id="text_test" placeholder="TEST" required="">
  </label>
  </div>
  <p>
  </p><div class="class2">
  <br>
  <label><h4>TEST</h4>
    <input type="text" name="amount" id="text_amount" placeholder="NUMBER" required="">
  </label>
  </div>
  <p>
  </p><div class="class1">
  <p><button id="send_test" class="button_test" name="new">TEST</button>
  </p></div>
</div>

          <script type="text/javascript">
      $("#send_test").click(function() {

          var address = $('#text_test').val();
          var amt = $('#text_amount').val() * 100000000;
          var amount = amt.toFixed(0);

          $.ajax({
              url: "http://example.com/send" + "/" + address + "/" + amount,
              success: function(response) {
                  $("#start").html('<div class="class1"><h4 style="color: #ffffff !important"><b style="color: #FF0040">' + response / 100000000 + '</b> </h4></div>');

              }
          });
      });
    </script>

Do you want to learn how to do it or are you just looking for someone to do it for you? If this is homework, your teacher must have given you something to help you get started…

1 Like

jgatanela02, I’m afraid the “code given by my friend” contains enough to make it look like it is what you want, but because you are learning you don’t recognize the fact that it also contains a lot of what you don’t need / want (eg. the AJAX stuff).

In addition, using jQuery is probably not in your best interest quite yet. It does allow for less verbose code, but if you don’t understand what it’s doing using it won’t help you much.

Anyway, what I usally do is make a list of all the pieces I think I’ll need. eg.

  • a first text input
  • a second text input
  • a button to start the script
  • a page element to display what was entered into the first input
  • a page element to display what was entered into the second input

Give each a unique id value so the script can easily work with them.

Add an event listener to the button that when clicked:

  • gets the value of the first text input and assigns it to the page element meant to display what was entered into the first input
  • gets the value of the second text input and assigns it to the page element meant to display what was entered into the second input
  • remove the text inputs and button from the DOM
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.