By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,638 Members | 2,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,638 IT Pros & Developers. It's quick & easy.

Storing a javascript variable in a php string

P: n/a
Hi,

I have the following javascript function:

<script type="text/javascript">

function HTMLEncode( text )
{
text = text.replace(/&/g, "&amp;") ;
text = text.replace(/"/g, "&quot;") ;
text = text.replace(/</g, "&lt;") ;
text = text.replace(/>/g, "&gt;") ;
text = text.replace(/'/g, "'") ;

return text ;
}

</script>

Now I want to store the content of 'text' in a php string.
Is that possible?

Thanks, Max
Jul 7 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Markus Schuster" <sc*****@sbox.tugraz.atwrote in message
news:44***********************@aconews.univie.ac.a t...
Hi,

I have the following javascript function:

<script type="text/javascript">

function HTMLEncode( text )
{
text = text.replace(/&/g, "&amp;") ;
text = text.replace(/"/g, "&quot;") ;
text = text.replace(/</g, "&lt;") ;
text = text.replace(/>/g, "&gt;") ;
text = text.replace(/'/g, "'") ;

return text ;
}

</script>

Now I want to store the content of 'text' in a php string.
Is that possible?

Yes, insert the text in an input element that is inside a form and submit
the form to the recieving php page.

By the way, a similar conversion function is available also in php, called
htmlentities.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
sp**@outolempi.net | Gedoon-S @ IRCnet | rot13(xv***@bhgbyrzcv.arg)
Jul 7 '06 #2

P: n/a
Kimmo Laine schrieb:
"Markus Schuster" <sc*****@sbox.tugraz.atwrote in message
news:44***********************@aconews.univie.ac.a t...
>Hi,

I have the following javascript function:

<script type="text/javascript">

function HTMLEncode( text )
{
text = text.replace(/&/g, "&amp;") ;
text = text.replace(/"/g, "&quot;") ;
text = text.replace(/</g, "&lt;") ;
text = text.replace(/>/g, "&gt;") ;
text = text.replace(/'/g, "'") ;

return text ;
}

</script>

Now I want to store the content of 'text' in a php string.
Is that possible?


Yes, insert the text in an input element that is inside a form and submit
the form to the recieving php page.
You mean it like that?

<form action="bla.php" method="post">
<input type="hidden" name="text" value=text>
<input type="submit" name="show" value="show">
</form>
Is that part ok?

value=text

Or how can I do it correctly?

Thanks, Max

By the way, a similar conversion function is available also in php, called
htmlentities.
Jul 7 '06 #3

P: n/a
Markus Schuster schrieb:
Kimmo Laine schrieb:
>"Markus Schuster" <sc*****@sbox.tugraz.atwrote in message
news:44***********************@aconews.univie.ac. at...
>>Hi,

I have the following javascript function:

<script type="text/javascript">

function HTMLEncode( text )
{
text = text.replace(/&/g, "&amp;") ;
text = text.replace(/"/g, "&quot;") ;
text = text.replace(/</g, "&lt;") ;
text = text.replace(/>/g, "&gt;") ;
text = text.replace(/'/g, "'") ;

return text ;
}

</script>

Now I want to store the content of 'text' in a php string.
Is that possible?


Yes, insert the text in an input element that is inside a form and
submit the form to the recieving php page.

You mean it like that?

<form action="bla.php" method="post">
<input type="hidden" name="text" value=text>
<input type="submit" name="show" value="show">
</form>
Is that part ok?

value=text

Or how can I do it correctly?

Thanks, Max

>By the way, a similar conversion function is available also in php,
called htmlentities.
Thanks I have it, it works fine.

Max
Jul 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.