javascript - Value from a text field is not returning anything -


i'm trying build little app user enters store name become alt text image , url of store become h ref, generate copy , paste code use on website.

the problem have when trying use vanilla javascript read value of store name nothing showing.

please see fiddle: http://jsfiddle.net/willwebdesigner/gvccm/

$(document).ready(function() {       //  creates method , prototype array splicing words     array.prototype.removebyvalue = function(val) {         for(var i=0; i<this.length; i++) {             if(this[i] == val) {                 this.splice(i, 1);                 break;             }         }     }      var mystore = {         storename: document.getelementbyid("storename").value,         url: document.getelementbyid("yoururl"),         instructions: "<p>please copy code above , paste webpage display shop4support logo , link store.</p>",          blacklogo: function() {             return "&lt;img src=&quot;https://www.shop4support.com/resources/home/information/informationforproviders/availables4s-bk.jpg&quot; alt=&quot;" + this.storename + " available on shop4support&quot; /&gt;";         }     }      $("#urlform").submit(function(e) {          // clear output form first         $(output).html(' ');         e.preventdefault();          // create array conditional statements         var address = [];         address = $(mystore.url).val().split("www");          // need put conditional in here detect if https://         if(address[0] === "https://") {             $(output)                 .slidedown()                 .prepend("&lt;a href=&quot;"+ $(mystore.url).val() + "&quot;&gt;" + mystore.blacklogo() + "&lt;/a&gt; ")                 .append(mystore.instructions);          } else if(address[0] === "http://") {             // remove http part off url             var removehttp = address;             removehttp.removebyvalue('http://');             $(output)                 .slidedown()                 .prepend("&lt;a href=&quot;https://www" + removehttp + "&quot;&gt;" + mystore.blacklogo() + "&lt;/a&gt; ")                 .append(mystore.instructions);          } else {             $(output)                 .slidedown()                 .prepend("&lt;a href=&quot;https://"+ $(mystore.url).val() + "&quot;&gt;" + mystore.blacklogo() + "&lt;/a&gt; ")                 .append(mystore.instructions);         }     }); }); 

thanks will

update code :

    $("#urlform").submit(function(e) {                mystore.storename= (document.getelementbyid("storename").value);    /* rest of code */     } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -