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 "<img src="https://www.shop4support.com/resources/home/information/informationforproviders/availables4s-bk.jpg" alt="" + this.storename + " available on shop4support" />"; } } $("#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("<a href=""+ $(mystore.url).val() + "">" + mystore.blacklogo() + "</a> ") .append(mystore.instructions); } else if(address[0] === "http://") { // remove http part off url var removehttp = address; removehttp.removebyvalue('http://'); $(output) .slidedown() .prepend("<a href="https://www" + removehttp + "">" + mystore.blacklogo() + "</a> ") .append(mystore.instructions); } else { $(output) .slidedown() .prepend("<a href="https://"+ $(mystore.url).val() + "">" + mystore.blacklogo() + "</a> ") .append(mystore.instructions); } }); });
thanks will
update code :
$("#urlform").submit(function(e) { mystore.storename= (document.getelementbyid("storename").value); /* rest of code */ }
Comments
Post a Comment