简体   繁体   中英

Need to display javascript value in anchor tag of jsp

I need to pass the userid variable through anchor tag .. Here I attached code for that.

Code :

<td colspan="2" align="right"><div align="center">User Id</div></td>
<td><input class="textbox" type="text" id="userid" ><a href="access.jsp?userid='+userid'" 
"></a></td></tr>

Javascript :

 var  userid ="MK";// this value is getting fetched correctly using document.getElementByName

Just I need to display in anchor tag.How can I do this?

Please, try to be more clear with your Question.
You should show all related parts of your code so people can figure out what exactly you need. Also Stackoverflow provides some markup so you can insert blocks of code - very useful, I recommend looking it up :)

Assuming you already have the anchor <a> tag

HTML

<a href="#" id="anchor"></a>

JS

// your code (fetching data) ...
document.getElementById('anchor').setAttribute('href', 'google.com?userid=" + userid)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM