0

I have string value in input box

<input name="to" value="hi.rand(1,10). my.rand(10,100).name is .rand(23,54).rand(1,4)" >

How to use $_GET['to'] if i want have

hi5 my54name is 335

Now i have got string "hi.rand(1,10). my.rand(10,100).name is .rand(23,54).rand(1,4)" but not execute like php function.

So how to format string in input box so PHP take it like variables.

Adam
  • 51
  • 1
  • 6

1 Answers1

1

You can create javascript using php. Something like this:

<script type="text/javascript">
<?php 
    $anyVar = "BONJOUR";    
?>
var value = "<?php echo $anyVar; ?>" ;
alert(value);
</script>

In the example I'm passing the value of my var $anyVar in PHP to the value var in javascript. So after the page loads and the script is parsed, you'll end up with something like this:

<script type="text/javascript">
var value = "BONJOUR" ;
alert(value);
</script>

You can as well write js code like this:

<script type="text/javascript">
<?php 
    $anyVar = "BONJOUR";    
?>
var value = "<?php echo $anyVar; ?>" ;
<?php echo 'alert(value);' ?>
</script>

Hope this helps.

Jair Reina
  • 2,606
  • 24
  • 19