Hello friends ,
Is there any way of passing javascript variable other than through the url
like i have
var content = document.myform.variable.value;
alert(content);
window.location="http://localhost/myfolder/demo.php?content="+content ;

When i echo my content(which has some hyperlinks) the hyperlinks wont work as the url is passed as

http://localhost/myfolder/demo.php?content=<STRONG><A%20href="http://localhost">nabih</A></STRONG>

due to whitespaces in content
Anyways it would be better if I could pass variables in the same page without use of the url thing
Can anybody show me a way out

Thanks in advance

Greg

    You'll have to setup a form, have the form method use post and then submit the form with your data. Sounds like kind of a pain. Why not just escape the spaces and then send it along? I was going to recommend using image.src as a transfer method, but it requires data to sit on the URL and you'd still have to escape the spaces (and other nasty characters).

      Well, there is a function in Javascript (I forget what it's called; it's been mentioned in these forums in the past day or so already, though) that encodes arbitrary text so that it won't mangle a URL. There is also a link in a stickied thread in the Coding Forum, entitled "Passing Javascript variables to PHP" that might be useful

        Thanks Astroteg and Weedpacket

        I know how to pass javascript variables via the URL

        The problem here is the string is too long

        like Weedpackets signature is passed as

        http://localhost/myfolder/demo.php?content=<STRONG><FONT%20face="Courier%20New"%20size=2>#%20sshnuke%2010.2.2.2%20-rootpw="Z1ON0101"%20<BR>Connecting%20to%2010.2.2.2:ssh%20...%20successful%20<BR>Attempting%20to%20exploit%20SSHv1%20CRC32%20...%20successful%20<BR>Resetting%20root%20password%20to%20"Z1ON0101"%20<BR>System%20open:%20Access%20Level%20(9)%20<BR>%20ssh%2010.2.2.2%20-l%20root%20<BR>root@10.2.2.2's%20password:</FONT></STRONG>

        When i access it with $_GET['content']
        It shows only some of the content

        I fancy your idea about escaping the spaces Astroteg
        Can anybody tell me how do I do that

        heres my javascript function that does that

        function submitForm() {
        updatecontent('content1');
        var content = document.Demo.content1.value;

        alert(content);
        
        window.location="http://localhost/myfolder/demo.php?content="+content;
        
        return false;

        }

        Thanks For those links Weedpacket .
        I just cant figure out how do i read that content from the url

        Greg๐Ÿ˜•

          Yipee thanks Astroteg and Weedpacket
          I escaped the string in javascript and it worked like a dream

          Greg

            Write a Reply...