Is there any limits on the length of a string or a URL?
Printable View
Is there any limits on the length of a string or a URL?
Thanks.
mine worked on 8193
that was in FX.
A client and/or host is not obliged to parse a URL greater than 255 characters. This means there is a soft limit of 255 characters, however most browsers have something like 2048 caracters.
The only rule is that you must be able to handle a URL upto 255 characters beyond that (well its up to the vendor).
Well, I'm creating the URL, so I'm just wondering if I need to try and shorten it or switch to a POST method. I just tested one that was 318 characters... and that's probably about the shortest it is going to be.
what about using cookies? They can be millions of characters long.
Using cookies for this purpose seems a little over the top.
Here's what I'm doing: I have a form that has several drop-downs and then other random form elements. Whenever they select something from the dropdown, I have to grab values from a database, hence, I have to reload the page, and when I do that, I don't want to lose all the input they have made, so I have a script that takes all the current values and writes them out to a URL and then when the page reloads, it grabs all the old values from the URL and stuffs them back into the form elements. Cookies seem like overkill for this.
That could start getting very annoying fo the user. If the query string is that long, then the form is probably quite large. when means the user chooses quite a bit of stuff which means the page refreshes quite a few times. This could really start bugging them.
If the database isn't that big, and its contents are not sensetive information. then you could load the whole thing into a JS array, then use that to change the form. This won't require a refresh, but if the DB is huge then of course this would get very cumboursome.
Well, the DB is of decent size.... so I don't know if I'd want to load everything into an array. And there are only 3 dropdowns that require the page to be refreshed, so it's really not that bad, and usually, those are the first 3 things that are picked.
The form also isn't that big, but it does have 3-4 textareas which is where the URL could get bloated (most cases not, however).
Could you explain how to load values into a javascript array in case I'd want to go that route? That is the part I don't understand... right now, all my SQL queries are in PHP and I'm connected to a MS SQL 2000 Server. Can you setup queries in Javascript?
I guess I should also add that all of this is internal work for my company... so speed/loadtime isn't much of an issue as the data is passed across 100mbps connections. That's why I wasn't afraid to use the refresh option. I'd imagine filling JavaScript arrays wouldn't take a terrible amount of time either.
Oh, in that case, you shold stick to how you're doing it.
JS can't do queries, but you could have JS dynamically change the form onBlur or onChange.
to load the db into an array, simply loop through each item in the db and enter it in the array. so:
PHP Code://untested
<script type="text/javascript">
myArray = new Array()
<?
//create a loop going through each item in the database
{
echo "myArray[myArray.length] = current_query";
}
?>
</script>
Well, I currently use the onChange method to reload the form. I'm not going to make them hit a button to do the refreshes... that would annoy them.
Maybe I'll implement the array idea as an upgrade in the future.
edit: Thanks for your help. :wave:
In the OnChange event, how about submitting the form to the same page? That'll be POST, and no URL problems.
You can retrieve the values, set the text/combo boxes.
If the user clicks submit, set a dirty variable, so that you know it's the real submit, and then process the info.
Now there's an idea I didn't think about... although the coding is already done to do it the other way.