Home > Net >  passing variable value to href argument
passing variable value to href argument

Time:04-16

I'm sure this is an easy one but I'm really stuck here..

This is the code

                            <td id="id"></td>
                            <td id="sku"></td>
                            <td id="name"></td>
                            <td id="type"></td>
                            <td id="price"></td>
                            <td id="shipping"></td>
                            <td id="description"></td>
                            <td id="image"></td>
                            <td>
                                <a href="/update-user?id=" </a>
                            </td>
                            <td>
                                <a  data-id= > </a>
                            </td>

I need to pass the value that's gonna be in the id="id" to the href id and data-id

The table is populated by this function here

var i = 0;

function next(){
    i  ;
    var value = $.ajax({
        type: "get",
        url: "http://localhost:3000/api/users",
        dataType: 'json'
    }).done(function (users) {
        console.log(users[i]);
        $('#id').text(users[i]._id)
        $('#sku').text(users[i].sku)
        $('#name').text(users[i].name)
        $('#type').text(users[i].type)
        $('#price').text(users[i].price)
        $('#shipping').text(users[i].shipping)
        $('#description').text(users[i].description)
        $('#image').html("<img src='" users[i].image "'/>")
    });
    return value.responseJSON;
}

Many thanks everyone!

CodePudding user response:

Is this what u mean?

  • Related