glennnall Posted September 16, 2010 Share Posted September 16, 2010 having this: $make = "<select name='make' id=\"make\" onchange=\"showModels(this.value)\">"; $make .= "<option value=\".$row['value'].\">Value</option>"; which calls this function: function showModels(str) { if (str=="") { document.getElementById("models").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("models").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","models.php?make="+str,true); xmlhttp.send(); if the value being returned has spaces, like "Convertible 2Door", it's only passing the value "Convertible" (causing some pretty poor queries, ya know)... can anyone see why? any idea what i'm talking about? Quote Link to comment https://forums.phpfreaks.com/topic/213612-not-sure-how-to-explain-onchangethisvalue-trimming-values-which-have-spaces/ Share on other sites More sharing options...
DarkSnake747 Posted September 17, 2010 Share Posted September 17, 2010 Well, I can see 2 areas of possible problems. The least likely of the two is with the with the request URL, you may want to URL encode that (though now that I think about the values and the string you're sending, I am not sure it would do anything). URL encoding in JavaScript is broken into detail here - http://www.javascripter.net/faq/escape.htm - however, this is probably not the problem. Have you checked the return value in some dev tools? Cause that would be a great way to see if the problem is server-side, or client side, or with the initial post I suppose. I am figuring its server-side with the page you are posting to. Can you give me a link to this page on the web? And more importantly, can you post the code on the file you are requesting with AJAX? The "handling" code that would build your return. Quote Link to comment https://forums.phpfreaks.com/topic/213612-not-sure-how-to-explain-onchangethisvalue-trimming-values-which-have-spaces/#findComment-1112063 Share on other sites More sharing options...
glennnall Posted September 19, 2010 Author Share Posted September 19, 2010 i appreciate your assistance. i ended up just replacing the spaces with _ in php and changing them back once the value was passed. worked out, and i don't know javascript well enough at all to try to understand why it wasn't passing the entire value as 'str' ... thanks again Quote Link to comment https://forums.phpfreaks.com/topic/213612-not-sure-how-to-explain-onchangethisvalue-trimming-values-which-have-spaces/#findComment-1112932 Share on other sites More sharing options...
DarkSnake747 Posted September 21, 2010 Share Posted September 21, 2010 No problem. Glad I could help... in some way I guess. If you want, you could check out my site and keep in contact. I often like helping people with programming and javascript is one language I am pretty good with. I just can help more if the question is directed to me. evileyegames.com - we have a programming help forum to... so, maybe useful for you. Quote Link to comment https://forums.phpfreaks.com/topic/213612-not-sure-how-to-explain-onchangethisvalue-trimming-values-which-have-spaces/#findComment-1113738 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.