Advertise with us

Html escape characters

Posted by  F Scott Fitzgerald
 2727  View(s)
Rate this:

I have the following:

<form name="input" method="get" action="http://site:8081/Default.aspx?DC=" target="foo" onSubmit="'', '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>
<input type="submit" value=">>"/>&nbsp;&nbsp;

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. 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... -->
    <input type="hidden" name="Type"/>
    <input type="submit" value=">>"/>

    and in Javascript...:

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

      Modified On Mar-31-2018 06:30:10 AM