Home > DeveloperSection > Forums > Html escape characters
F Scott Fitzgerald
F Scott Fitzgerald

Total Post:29

Posted on    October-05-2013 9:14 AM


 1 Reply(s)
 1389  View(s)
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>
<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?

C G E Mannerheim
C G E Mannerheim

Total Post:29

Posted on    October-05-2013 9:32 AM

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
    window.open('', 'foo', 'width=1100 height=500,status=no,resizable=yes,scrollbars=yes')
    return true;

Don't want to miss updates? Please click the below button!

Follow MindStick