HTML ESCAPE CHARACTERS

F Scott Fitzgerald

Total Post:29

Points:203
Posted by  F Scott Fitzgerald
HTML5 
 1830  View(s)
Ratings:
Rate this:

I have the following:

<form name="input" method="get" action="http://site:8081/Default.aspx?DC=" target="foo" onSubmit="window.open('', 'foo', 'width=1100 height=500,status=no,resizable=yes,scrollbars=yes')">
<select name="dc">
<option value="1&Type=type1">1</option>
<option value="2&Type=type2">2</option>
<option value="3&Type=type3">3</option>
</select>
<input type="submit" value=">>"/>&nbsp;&nbsp;
</form>

Basically my querystring should be something like dc=1&Type=type1 the problem I have is that when I click the >> button above the html screws up the stirng by changing & to %26 and = to %3D

How can I make the value stay as I have it in the code above?

  1. C G E Mannerheim

    Post:29

    Points:203
    Re: Html escape characters

    Yes, that's the expected behaviour, the HTTP GET works this way, values are encoded to difference from keys. In GET, browsers append key=value pairs separated by '&' and starting with a '?'; you shouldn't specify them by yourself in the url.

    I think you should change your code in this way, maybe it's what you want to get:

    <form name="input" method="get" action="http://site:8083/Default.aspx" target="foo" onSubmit="updateType()">
    <select name="DC">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <!-- etc... -->
    </select>
    <input type="hidden" name="Type"/>
    <input type="submit" value=">>"/>
    </form>

    and in Javascript...:

    function updateType(){
        // set up 'Type'
        document.forms[0].Type.value = 'Type' + document.forms[0].DC.value;
        // open popup
        window.open('', 'foo', 'width=1100 height=500,status=no,resizable=yes,scrollbars=yes')
        return true;
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!