Page 1 of 1

# anchor causes problems

Posted: Mon Sep 06, 2004 5:58 am
by gurjit
hi all,

i have a url string i pass through as follows:

http://www.mydomain.com/page.php?id=1&w ... &adr2=king road&city=london

the # in adr1 variable causes the page to stop printing adr2,city.

any variable after adr1 will not print on the page.

how can i stop this from happening?

Posted: Mon Sep 06, 2004 6:05 am
by feyd
urlencode the #.. it's a url hash marking.

%23 = #

Posted: Mon Sep 06, 2004 6:27 am
by gurjit
I have a javascript that creates the string to pass through. how can i do this in the javascript?

Code: Select all

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--

function passall () &#123;


makestring = "a=a" 
for (i=0;i<document.form1.elements.length;i++) &#123;
	
	if (document.form1.elements&#1111;i].type == "radio" || document.form1.elements&#1111;i].type == "checkbox") &#123;
		if (document.form1.elements&#1111;i].checked == true) &#123;
			makestring = makestring + "&" + document.form1.elements&#1111;i].name + "=" + document.form1.elements&#1111;i].value
		&#125;
	&#125; 
	else 
	&#123;
	makestring = makestring + "&" + document.form1.elements&#1111;i].name + "=" + document.form1.elements&#1111;i].value
	&#125;
&#125;
document.location.href = "principal_user_edit.php?stop=stop&" + makestring

&#125;

//-->
</SCRIPT>

feyd | please use the forum's tags!

Posted: Mon Sep 06, 2004 6:30 am
by feyd
Javascript has a lovely little function called 'escape' that does it.

Posted: Mon Sep 06, 2004 6:31 am
by timvw
I don't know JavaScript very well, but i think you could use escape function.

Posted: Mon Sep 06, 2004 7:25 am
by gurjit
you were right...the escape function around the value part worked great.

thanks all...