Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
48
rated 0 times [  52] [ 4]  / answers: 1 / hits: 30343  / 14 Years ago, fri, september 24, 2010, 12:00:00

Using jQuery, how do I get the value from a textbox and then load a new page based on the value?



For example, lets say the textbox contains hello on page1.php, how do I change the default behavior of an anchor tag to now load the following



page2.php?txt=hello



I have the following so far:



<script type=text/javascript>
$(document).ready(function(){
$(a.mylink).click(function(event){
alert(link clicked);
event.preventDefault();
});
});
</script>

More From » jquery

 Answers
48

Html



    <input type=text id=demoQuery />
<a id='demoLink' href='javascript:'>Iam a link</a>


Javascript



jQuery('#demoLink').bind('click',function(e){
e.preventDefault();
document.location.href=someUrl.php?text=+ jQuery('#demoQuery').val();
});

[#95512] Wednesday, September 22, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leog

Total Points: 225
Total Questions: 113
Total Answers: 118

Location: Oman
Member since Wed, Apr 12, 2023
1 Year ago
;