Jump to content

Defining Anchor Tag Using HTML Form


epseix

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.