简体   繁体   中英

Concatenate href value and jquery result in href of anchor tag

Below is my code present in my application :

<input id="input" value="Testing" />

<a  href="/captures/getTranslation/?TB_iframe=true&amp;modal=true&amp;height=380&amp;width=670&amp;" name="Signup" id="signuplink" title="Post" > Test </a>

I am posting some data to one page, i am getting all the attached parameter in my result page.

Here i want to know how do i pass text value with href of anchor tag.

I tried something like this, but it's not working :

<a  href="/captures/getTranslation/?TB_iframe=true&amp;modal=true&amp;height=380&amp;width=670&amp;textBoxValue=$('#input').val();" name="Signup" id="signuplink" title="Post" > Test </a>

I have used overlay on onclick of anchor tag, if i add function over there then overlay wont come, due to that im skipping function call on any events.

I am using jquery library also. But in result page i am not getting textBoxValue parameter.

Please suggest me guys, how to append parameter(input box value) in href attribute of achor tag using jquery

Thanks

-Pravin

Try changing the a to a button, or span and adding an onclick event, you can then redirect the users where ever you want with values from any element.

something like this:

<a  onclick="javascript:GoToUrl();"> Test </a>


<script type="javascript">

function GoToUrl()
{
var url = "/captures/getTranslation/?TB_iframe=true&amp;modal=true&amp;height=380&amp;width=670&amp;" + textBoxValue=$('#input').val();

window.location.href = url;
}

</script>

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