Reputation: 5274
I have a form and want to pass a value from it to my javascript - and use this value to create a javascript variable.
Im a newbie at javascript and cant get it to work.
Here is my code:
<input id="bartype" name="bartype" type="text" value="<?php echo $bartype; ?>" style="display:none" />
I want to grab the value and in my javascript create this var:
var type = $('#bartype');
var targetUrl = 'listing.php?page=$'+type;
How do I do this?
Thanks a lot
Upvotes: 0
Views: 230
Reputation: 1271
var type = $('#bartype').val();
var targetUrl = 'listing.php?page='+type;
Use google developer tools or firebug to debug javascript
console.log($('#bartype'))
You should go trough some tutorials:
http://docs.jquery.com/Tutorials
Upvotes: 3