epseix Posted January 16, 2012 Share Posted January 16, 2012 Bit confused here... Have the following form which allows me to enter a search term, define the table (tbl) from which to search and limit of results, however I also need to define an anchor tag at the end of the url which matches the tbl. eg. <div class="b2"> <form action="/admin/home.php" method="GET"> <div class="row"> <input name="search" size="19" type="text" value=""> </div> <div class="row"> <select name="tbl"> <option selected>blog</option> <option>book_me</option> <option>comments</option> <option>events</option> <option>faq</option> <option>links</option> <option>workshops</option> </select> </div> <div class="row"> <select name="limit"> <option selected>50</option> <option>100</option> <option>250</option> <option>500</option> <option>1000</option> <option value="">All</option> </select> </div> <div class="row"><input class="submit" type="submit" value="Go!"></div> </form> </div> This code will produce: /admin/home.php?search=&tbl=blog&limit=50 ...wheras I need it to produce... /admin/home.php?search=&tbl=blog&limit=50#blog OR /admin/home.php?search=&tbl=events&limit=50#events OR /admin/home.php?search=&tbl=workshops&limit=50#workshops etc. Any ideas? Link to comment https://forums.phpfreaks.com/topic/255160-defining-anchor-tag-using-html-form/ Share on other sites More sharing options...
Adam Posted January 19, 2012 Share Posted January 19, 2012 I don't really understand why you need to do this? Nevertheless you can simply detect the form submission and inject the value of the select before allowing it to continue: <form action="/admin/home.php" method="GET" name="search"> document.search.onsubmit = function() { this.action = this.action.substr(0, this.action.indexOf('#') + 1); this.action += '#' + this.tbl.value; } The added name attribute in the form tag is important. Link to comment https://forums.phpfreaks.com/topic/255160-defining-anchor-tag-using-html-form/#findComment-1309082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.