/    Sign up×
Community /Pin to ProfileBookmark

Passing data error

I wonder if someone could please assit. I have the following function that populates the URL with variables from lists that the user selects from.

function MM_openBrWindow_rep(theURL,winName,features) {
if(document.getElementById(‘show_bookings’).checked == false && document.getElementById(‘show_quotes’).checked == false){
alert(‘Please Select Quotation & Booking Display Preference’);
return false;
}
var pr = document.getElementById(‘to_date’).value;
if(pr.length==0){
alert(‘Please Select The Last Date of Report’);
return false;
}
pr = document.getElementById(‘from_date’).value;
if(pr.length==0){
alert(‘Please Select The Begining Date of Report’);
return false;
}

var len = document.getElementById(‘to_list’).length;
if(len < 2){
alert(‘The Must Be Grouped By Atleast 2 Criteria’);
return false;
}
var chosen = “”;
for (i = 0; i < len; i++) {
chosen = chosen + document.getElementById(‘to_list’)[i].value + “|”
}
len = document.getElementById(‘user_list’).length;
var all_users = “0”;
if(document.getElementById(‘user_list’).options[0].selected == true && document.getElementById(‘user_list’).options[0].value == “0” && len != 1){
all_users = “1”;
document.getElementById(‘user_list’).options[0].selected = false;
for (i = 1; i < len; i++) {
document.getElementById(‘user_list’).options[i].selected = true;
}
}
var chosen_user = “”;
for (i = 0; i < len; i++) {
if (document.getElementById(‘user_list’)[i].selected) {
chosen_user = chosen_user + document.getElementById(‘user_list’)[i].value + “|”;
}
}
if(all_users==”1″){
for (i = 1; i < len; i++) {
document.getElementById(‘user_list’).options[i].selected = false;
}
document.getElementById(‘user_list’).options[0].selected = true;
}
len = document.getElementById(‘paper_list’).length;
var all_papers = “0”;
if(document.getElementById(‘paper_list’).options[0].selected == true && document.getElementById(‘paper_list’).options[0].value == “0” && len != 1){
all_papers = “1”;
document.getElementById(‘paper_list’).options[0].selected = false;
for (i = 1; i < len; i++) {
document.getElementById(‘paper_list’).options[i].selected = true;
}
}
var chosen_paper = “”;
for (i = 0; i < len; i++) {
if (document.getElementById(‘paper_list’)[i].selected) {
chosen_paper = chosen_paper + document.getElementById(‘paper_list’)[i].value + “|”;
}
}
if(all_papers==”1″){
for (i = 1; i < len; i++) {
document.getElementById(‘paper_list’).options[i].selected = false;
}
document.getElementById(‘paper_list’).options[0].selected = true;
}
len = document.getElementById(‘client_list’).length;
var all_clients = “0”;
if(document.getElementById(‘client_list’).options[0].selected == true && document.getElementById(‘client_list’).options[0].value == “0” && len != 1){
all_clients = “1”;
document.getElementById(‘client_list’).options[0].selected = false;
for (i = 1; i < len; i++) {
document.getElementById(‘client_list’).options[i].selected = true;
}
}
var chosen_client = “”;
for (i = 0; i < len; i++) {
if (document.getElementById(‘client_list’)[i].selected) {
chosen_client = chosen_client + document.getElementById(‘client_list’)[i].value + “|”;
}
}
if(all_clients==”1″){
for (i = 1; i < len; i++) {
document.getElementById(‘client_list’).options[i].selected = false;
}
document.getElementById(‘client_list’).options[0].selected = true;
}
theURL = theURL + “&chosen=” + chosen + “&user=” + chosen_user + “&clients=” + chosen_client + “&papers=” + chosen_paper + “&totals=” + document.getElementById(‘show_totals’).checked + “&booking=” + document.getElementById(‘show_bookings’).checked + “&quotation=” + document.getElementById(‘show_quotes’).checked + “&totals=” + document.getElementById(‘show_totals’).checked + “&details=” + document.getElementById(‘show_details_cb1’).checked + “&from_date=” + document.getElementById(‘from_date’).value + “&to_date=” + document.getElementById(‘to_date’).value + “&discount=” + document.getElementById(‘show_discount’).checked + “&all_clients=” + all_clients + “&all_users=” + all_users + “&all_papers=” + all_papers + “&attach=0”;
window.open(theURL,winName,features);

}

The problem is that when I select a few clients the function works and passes the correct data to the URL.

However, if i select ALL clients and ALL publications the URL is string that is passed is cut short and the whole string is not passed. Works in FF but not in IE

Is there a work around for IE?

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@007JulienJan 15.2012 — &#171; Extremely long URLs are usually a mistake. URLs over 2,000 characters will not work in the most popular web browser. Don't use them if you intend your site to work for the majority of Internet users. &#187; Stackoverflow citation.

Make it shorter (use c for clients, b for booking,... numericals values, binary numbers ... an so on) or use a form with a POST method (a javascript question) !
Copy linkTweet thisAlerts:
@PoklerRebelauthorJan 16.2012 — Thanks for the reply, much appreciated, but excuse the questions.

I realise that long URL strings are causing issues and problems, but is there another approach i could use to pass the client, publication and user id's in the URL by shortening it. The app has grown as more and more clients and users have been added.

This is what the URL string should look like:

http://domain/reports/user_report.php?exp=no&chosen=campaign_summary.created_dinaya|campaign_summary.uid|campaign_details.pid|&user=27|20|19|15|17|26|2|24|28|1|23|25|16|13|21|18|22|14|&clients=338|186|647|454|245|434|453|486|147|300|246|196|657|248|436|391|648|567|569|328|575|451|235|422|592|231|232|398|317|200|488|499|233|534|163|150|432|318|225|207|221|220|247|239|222|406|521|418|419|350|204|265|389|396|206|572|470|421|557|270|294|175|308|653|376|485|607|450|288|651|544|659|493|262|357|185|171|408|548|469|152|177|192|492|312|517|455|282|495|503|125|490|429|577|242|259|609|561|198|447|639|241|349|379|427|352|611|374|405|537|439|494|482|380|296|550|269|236|303|134|178|646|533|327|335|415|506|315|582|329|461|500|135|628|604|333|354|664|513|554|412|164|165|512|336|210|342|218|215|219|140|216|217|136|213|613|271|188|466|638|394|331|559|410|266|460|179|553|584|174|402|359|630|126|529|365|173|631|313|536|276|519|291|417|626|625|624|623|589|130|144|285|622|297|131|663|528|530|615|597|595|596|594|602|172|608|654|347|457|254|148|224|223|416|481|261|619|358|531|620|321|440|603|156|590|426|542|479|411|251|203|340|184|463|516|133|640|395|660|573|658|551|614|362|629|480|127|268|137|368|473|491|361|645|252|211|413|565|166|385|472|305|588|214|591|612|496|420|464|511|387|337|462|348|264|281|332|397|280|306|334|543|616|571|541|279|568|650|444|409|456|535|580|520|367|237|238|139|330|404|364|&papers=13|1|27|30|29|28|35|23|3|2|26|24|25|4|&totals=true&booking=true&quotation=true&totals=true&details=true&from_date=01-01-2012&to_date=15-01-2012&discount=true&all_clients=0&all_users=1&all_papers=1&attach=0

and this is what the URL string looks like with to many clients; Total characters = 2083:

http://domain/reports/user_report.php?exp=no&chosen=campaign_summary.created_dinaya|campaign_summary.uid|campaign_details.pid|&user=27|20|19|15|17|26|2|24|28|1|23|25|16|13|21|18|22|14|&clients=338|186|647|454|245|434|453|486|147|300|246|196|657|248|436|391|648|567|569|328|575|451|235|422|592|231|232|398|317|200|488|499|233|534|163|150|432|318|225|207|221|220|247|239|222|406|521|418|419|350|204|265|389|396|206|572|470|421|557|270|294|175|308|653|376|485|607|450|288|651|544|659|493|262|357|185|171|408|548|469|152|177|192|492|312|517|455|282|495|503|125|490|429|577|242|259|609|561|198|447|639|241|349|379|427|352|611|374|405|537|439|494|482|380|296|550|269|236|303|134|178|646|533|327|335|415|506|315|582|329|461|500|135|628|604|333|354|664|513|554|412|164|165|512|336|210|342|218|215|219|140|216|217|136|213|613|271|188|466|638|394|331|559|410|266|460|179|553|584|174|402|359|630|126|529|365|173|631|313|536|276|519|291|417|626|625|624|623|589|130|144|285|622|297|131|663|528|530|615|597|595|596|594|602|172|608|654|347|457|254|148|224|223|416|481|261|619|358|531|620|321|440|603|156|590|426|542|479|411|251|203|340|184|463|516|133|640|395|660|573|658|551|614|362|629|480|127|268|137|368|473|491|361|645|252|211|413|565|166|385|472|305|588|214|591|612|496|420|464|511|387|337|462|348|264|281|332|397|280|306|334|543|616|571|541|279|568|650|444|409|456|535|580|520|367|237|238|139|330|404|364|160|194|181|366|598|311|388|471|545|435|123|593|610|576|209|322|256|145|229|502|661|556|314|564|433|154|555|304|599|510|483|240|230|319|250|621|587|151|274|195|562|505|476|570|253|600|487|549|146|523|208|345|514|228|227|226|187|526|414|384|446|346|518|344|452|243|662|566|538|392|652|155|371|532|363|539|244|369|522|176|295|601|637|403|255|477|290|632|202|579|193|515|431|484|257|197|272|552|258|289|353|273|524|400|307|249|489|442|634|635|636|443|286|448|504|167|540|498|501|138|563|474|585|263|509|161|168|169|458|560|386|157|158|478|475|399|356|449|355|525|170|302|586|260|578|339|212|299|441|649|124|656|655|438|558|143|128|122|546|309|234|149|393|407|191|199|

What other approach could I use?
Copy linkTweet thisAlerts:
@PoklerRebelauthorJan 16.2012 — I know there are a lot of guru's out there and I am sure someone can help me... ?
Copy linkTweet thisAlerts:
@PoklerRebelauthorJan 16.2012 — This is what the URL string should look like:

/reports/user_report.php?exp=no&chosen=campaign_summary.created_dinaya|campaign_summary.uid|campaign_details.pid|&user=27|20|19|15|17|26|2|24|28|1|23|25|16|13|21|18|22|14|&clients=338|186|647|454|245|434|453|486|147|300|246|196|657|248|436|391|648|567|569|328|575|451|235|422|592|231|232|398|317|200|488|499|233|534|163|150|432|318|225|207|221|220|247|239|222|406|521|418|419|350|204|265|389|396|206|572|470|421|557|270|294|175|308|653|376|485|607|450|288|651|544|659|493|262|357|185|171|408|548|469|152|177|192|492|312|517|455|282|495|503|125|490|429|577|242|259|609|561|198|447|639|241|349|379|427|352|611|374|405|537|439|494|482|380|296|550|269|236|303|134|178|646|533|327|335|415|506|315|582|329|461|500|135|628|604|333|354|664|513|554|412|164|165|512|336|210|342|218|215|219|140|216|217|136|213|613|271|188|466|638|394|331|559|410|266|460|179|553|584|174|402|359|630|126|529|365|173|631|313|536|276|519|291|417|626|625|624|623|589|130|144|285|622|297|131|663|528|530|615|597|595|596|594|602|172|608|654|347|457|254|148|224|223|416|481|261|619|358|531|620|321|440|603|156|590|426|542|479|411|251|203|340|184|463|516|133|640|395|660|573|658|551|614|362|629|480|127|268|137|368|473|491|361|645|252|211|413|565|166|385|472|305|588|214|591|612|496|420|464|511|387|337|462|348|264|281|332|397|280|306|334|543|616|571|541|279|568|650|444|409|456|535|580|520|367|237|238|139|330|404|364|&papers=13|1|27|30|29|28|35|23|3|2|26|24|25|4|&totals=true&booking=true&quotation=true&totals=true&details=true&from_date=01-01-2012&to_date=15-01-2012&discount=true&all_clients=0&all_users=1&all_papers=1&attach=0

and this is what the URL string looks like with to many clients; Total characters = 2083:

/reports/user_report.php?exp=no&chosen=campaign_summary.created_dinaya|campaign_summary.uid|campaign_details.pid|&user=27|20|19|15|17|26|2|24|28|1|23|25|16|13|21|18|22|14|&clients=338|186|647|454|245|434|453|486|147|300|246|196|657|248|436|391|648|567|569|328|575|451|235|422|592|231|232|398|317|200|488|499|233|534|163|150|432|318|225|207|221|220|247|239|222|406|521|418|419|350|204|265|389|396|206|572|470|421|557|270|294|175|308|653|376|485|607|450|288|651|544|659|493|262|357|185|171|408|548|469|152|177|192|492|312|517|455|282|495|503|125|490|429|577|242|259|609|561|198|447|639|241|349|379|427|352|611|374|405|537|439|494|482|380|296|550|269|236|303|134|178|646|533|327|335|415|506|315|582|329|461|500|135|628|604|333|354|664|513|554|412|164|165|512|336|210|342|218|215|219|140|216|217|136|213|613|271|188|466|638|394|331|559|410|266|460|179|553|584|174|402|359|630|126|529|365|173|631|313|536|276|519|291|417|626|625|624|623|589|130|144|285|622|297|131|663|528|530|615|597|595|596|594|602|172|608|654|347|457|254|148|224|223|416|481|261|619|358|531|620|321|440|603|156|590|426|542|479|411|251|203|340|184|463|516|133|640|395|660|573|658|551|614|362|629|480|127|268|137|368|473|491|361|645|252|211|413|565|166|385|472|305|588|214|591|612|496|420|464|511|387|337|462|348|264|281|332|397|280|306|334|543|616|571|541|279|568|650|444|409|456|535|580|520|367|237|238|139|330|404|364|160|194|181|366|598|311|388|471|545|435|123|593|610|576|209|322|256|145|229|502|661|556|314|564|433|154|555|304|599|510|483|240|230|319|250|621|587|151|274|195|562|505|476|570|253|600|487|549|146|523|208|345|514|228|227|226|187|526|414|384|446|346|518|344|452|243|662|566|538|392|652|155|371|532|363|539|244|369|522|176|295|601|637|403|255|477|290|632|202|579|193|515|431|484|257|197|272|552|258|289|353|273|524|400|307|249|489|442|634|635|636|443|286|448|504|167|540|498|501|138|563|474|585|263|509|161|168|169|458|560|386|157|158|478|475|399|356|449|355|525|170|302|586|260|578|339|212|299|441|649|124|656|655|438|558|143|128|122|546|309|234|149|393|407|191|199|

Sorry for posting link and not actual URL string
Copy linkTweet thisAlerts:
@ssystemsJan 16.2012 — Have you looked at json?
Copy linkTweet thisAlerts:
@PoklerRebelauthorJan 16.2012 — No I have not? How do u suggext I use json in this instance?
Copy linkTweet thisAlerts:
@007JulienJan 16.2012 — It's always possible to transform a set of integer values in an array (for example bin) of binary integers... (less than 2^16)

For example 27 => 1 bit with the range 27 => bin[Math.round(27/16)]=1<<(27&#37;16);

Adding all this values for 27|20|19|15|17|26|2|24|28|1|23|25|16|13|21|18|22|14 give two integers (32 octets for 46 values ???)
Copy linkTweet thisAlerts:
@ssystemsJan 16.2012 — Yes it is possible. But wouldn't it be a problem on the processing? e.g. 5 could be 3+2 or 4+1.
Copy linkTweet thisAlerts:
@007JulienJan 17.2012 — No 5 is always represented by 2^5 which is 32.
[code=html]var tab="27|20|19|15|17|26|2|24|28|1|23|25|16|13|21|18|22|14".split('|');
var bin=[0,0];
for (i=0;i<tab.length;i++) bin[Math.floor(tab[i]/16)]+=1<<(tab[i]%16);
alert(bin);// give 57350,8191 which represent all the preceding numbers (by disregarding the order).
[/code]
We build an unique binary number with 1 at the rank k, if k is in the list (and 0 if not). To store this big number we cut it in slices of 16 bits and obtain integers less than 65536. It's easy to build functions or class to manage sets of numbers. Besides this method could apply to the difference of the numbers and there minimum...

Json, which repeat pointlessly the names of keys, seems not a good idea. Nevertheless a simple post, or a batch processing could be probably better...

EDIT : with this method the first client string, length 301, become bin.toString()

,,,,,,,57344,7020,4441,63608,1550,55632,65516,63875,23014,63336,10128,37697,27414,65410,28759,46821,6401,31914,49012,11359,37269,62444,33637,64807,33945,947,58351,42705,48002,61778,39997,55547,49399,28129,414

which length is 208 !
[CODE]var clt="338|186|647|454|245|434|453|4 86|147|300|246|196|657|248|436|391|648|567|569|328|575|451|235|422|592|231|232|398|317|200|488|499|2 33|534|163|150|432|318|225|207|221|220|247|239|222|406|521|418|419|350|204|265|389|396|206|572|470|4 21|557|270|294|175|308|653|376|485|607|450|288|651|544|659|493|262|357|185|171|408|548|469|152|177|1 92|492|312|517|455|282|495|503|125|490|429|577|242|259|609|561|198|447|639|241|349|379|427|352|611|3 74|405|537|439|494|482|380|296|550|269|236|303|134|178|646|533|327|335|415|506|315|582|329|461|500|1 35|628|604|333|354|664|513|554|412|164|165|512|336|210|342|218|215|219|140|216|217|136|213|613|271|1 88|466|638|394|331|559|410|266|460|179|553|584|174|402|359|630|126|529|365|173|631|313|536|276|519|2 91|417|626|625|624|623|589|130|144|285|622|297|131|663|528|530|615|597|595|596|594|602|172|608|654|3 47|457|254|148|224|223|416|481|261|619|358|531|620|321|440|603|156|590|426|542|479|411|251|203|340|1 84|463|516|133|640|395|660|573|658|551|614|362|629|480|127|268|137|368|473|491|361|645|252|211|413|5 65|166|385|472|305|588|214|591|612|496|420|464|511|387|337|462|348|264|281|332|397|280|306|334|543|6 16|571|541|279|568|650|444|409|456|535|580|520|367|237|238|139|330|404|364".split('|');
var bin=[];
for (i=0;i<clt.length;i++) if (typeof(bin[Math.floor(clt[i]/16)])!='undefined') bin[Math.floor(clt[i]/16)]+=1<<(clt[i]%16);
else bin[Math.floor(clt[i]/16)]=1<<(clt[i]%16);
document.getElementById('rsp').innerHTML=bin.toString()+'<br>'+clt.length+'<br>'+bin.toString().length;[/CODE]
Copy linkTweet thisAlerts:
@ssystemsJan 17.2012 — This was certainly was added to my cookbook. Did not notice the shifting. In any case just keep in mind that this is somewhat logarithmic in nature which shouldn't be much of an issue but is worth noting

[CODE]var st="338|186";
var clt = st.split('|');
var bin=[];
for (i=0;i<clt.length;i++) if (typeof(bin[Math.floor(clt[i]/16)])!='undefined') bin[Math.floor(clt[i]/16)]+=1<<(clt[i]&#37;16);
else bin[Math.floor(clt[i]/16)]=1<<(clt[i]%16);
document.getElementById('rsp').innerHTML=bin.toString()+'<br>'+st.length+'<br>'+clt.length+'<br>'+bin.toString().length;[/CODE]


That being said I would still utilize JSON combined with this new knowledge due to the nature of the application and the it's duplex capabilities.

@Julien: Thanks for the new info

@Rebel: Let us know if you followed the discussion
Copy linkTweet thisAlerts:
@007JulienJan 17.2012 — I make mistakes with space (or tab) in the clt values and with [I]clt.length[/I] which is to replace with [I]clt.toString().length[/I]. Then the initial length of 1203 is reduced to 208 !
×

Success!

Help @PoklerRebel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...