0

If YZ56765ZX is entered into the input field, the form should generate the following URL:

http://www.example.com/quick-access/?track-code#trackingIds=YZ56765ZX

The form:

<form enctype="text/plain" action="http://www.example.com/quick-access/">
    <input type="text" name="track-code#trackingIds" id="keys" />
    <button type="submit">Search</button>
</form>

The problem is that I am unable to generate a URL that includes the: # character. The # will become %23 instead.

unor
  • 92,415
  • 26
  • 211
  • 360
apasajja
  • 576
  • 2
  • 6
  • 20
  • What are you using to generate the URL? What programming language? Do you have a program that you have now that is generating HTML that is not doing what you want? – Andy Lester Mar 26 '15 at 03:23
  • 1
    Do you have control at the receiving end? The url encoding can be reversed by the receiver to get the %23 converted back to #. – Always Learning Mar 26 '15 at 03:26
  • `website.com` is external website not under my control. This html form for check tracking code. – apasajja Mar 26 '15 at 06:32

1 Answers1

1

I think you can't use these kind of reserved symbols. Consider reading "Reserved Characters" (RFC 3986).

You can still try something like this JSFiddle.

document.getElementsByTagName('form')[0].onsubmit = function() {
    this.action += '?track-code#trackingIds=' + this.keys.value;
}
<form enctype="text/plain" action="http://www.example.com/quick-access/">
    <input type="text" id="keys" />
    <button type="submit">Search</button>
</form>
Community
  • 1
  • 1
N K
  • 3,217
  • 5
  • 23
  • 38