jquery - So I have an HTML link that needs one attribute which exists in MVC input -


<a href="https://yourwater.oregon.gov/dcoliform.php?pwsno=$('#pws').val()" target="_blank" id="dataonline">data online</a> 

the mvc input is:

@html.textboxfor(model => model.pws) 

i've referenced input in sorts of javascript document.onload(). not sure how send in url name/value pair url correct. won't send 5 digit number. should like in webpage when gets it:

href="https://yourwater.oregon.gov/dcoliform.php?pwsno=99999 

(99999 water system number used example)

if have html -

<a href="https://yourwater.oregon.gov/dcoliform.php?pwsno=" target="_blank" id="dataonline">data online</a> <input type="text" id="pws" value="99999" /> 

you can write script this. can in click handler or on page load or onchange, depends on requirement.

var hreftxt = $("#dataonline").attr("href"); $("#dataonline").attr("href", hreftxt + $('#pws').val()); 

check jsfiddle:


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -