1 month ago

Prepopulate text field in a JQUERY with a URL parameter value

Posted 1 month ago by screwtape_mk

I want to pre - populate text box (and gray it out for editing) with a URL parameter value inside a jquery snippet of code:

The Jquery code:

jQuery(document).ready( function () {
        $("#append").click( function(e) {
        $(".inc").append('<div class="controls">\
                <input class="form-control" type="text" name="textbox" placeholder="email">\
                <input class="form-control" type="text" name="text" placeholder="@domain">\
                <a href="#" class="remove_this btn btn-danger">remove</a>\
        return false;

    jQuery(document).on('click', '.remove_this', function() {
        return false;
    $("input[type=submit]").click(function(e) {
        $.map($(".inc :text"), function(el) {
          return el.value

The specific text field i want to prepopulate :

<input class="form-control" type="text" name="domain" placeholder="@domain">\

The function i have for obtaining the said parameter value:

function GetURLParameter(sParam)


    	var sPageURL =;

    	var sURLVariables = sPageURL.split('&');

    for (var i = 0; i < sURLVariables.length; i++)


        var sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] == sParam)


            return sParameterName[1];




i am not sure how to evaluate this within those commas

Please sign in or create an account to participate in this conversation.