I want to set a group of button, click them ,change the value and show into one div. Then clear the HTML tags and put the value into form input value. but it always fail. I put the $s1 in the form input value directly. It show something wrong, I check it under firefox firebug, the form input value show <p> tag in it, so I use strip_tags($s1), it lost the value show empty. I copy the echo $s1 from firefox firebug source code and name it as $s2, then strip_tags($s2), it can work well. Then I make a session start on the top of the code and set $s1=$_SESSION['s1'],then put the $_SESSION['s1'] into the form input value, it also show nothing. Where is wrong? and how to put a pure (no HTML tags)$s1 value into the form input value? Thanks. <script language="javascript"> function thelink(title) { document.getElementById('div1').innerHTML = title; } </script> <li><a href="#" title="http://www.google.com" onclick="thelink('http://www.google.com')">google</a></li> <li><a href="#" title="http://www.bbc.co.uk" onclick="thelink('http://www.bbc.co.uk')">bbc</a></li> <li><a href="#" title="http://www.cnn.com" onclick="thelink('http://www.cnn.com')">cnn</a></li> <p id="div1"></p> <? $s1 ="<p id=\"div1\"></p>"; $s2="<p id=\"div1\">http://www.cnn.com</p>"; echo $s1; echo $s2; $s3="<form name=\"input\" action=\"8.php\" method=\"get\"><input id=\"name\" name=\"name\" value=\"".strip_tags($s1)."\" type=\"hidden\"><input type=\"submit\" value=\"Submit\" /></form> "; echo $s3; ?> <? echo $_GET['post']; ?> HTML:
Hi, I have found something wrong. The value in <p id="div1"></p> can not be stored. Even I add a session.I checked it in the Firefox Firebug, it display empty. How to remember the value in <p id="div1"></p>? Is it just a virtual value? Strangely... use echo $_SESSION['aa'] can clearly see the value... <?php session_start(); ?> <script language="javascript"> function thelink(title) { document.getElementById('div1').innerHTML = title; } </script> <li><a href="#" title="http://www.google.com" onclick="thelink('http://www.google.com')">google</a></li> <li><a href="#" title="http://www.bbc.co.uk" onclick="thelink('http://www.bbc.co.uk')">bbc</a></li> <li><a href="#" title="http://www.cnn.com" onclick="thelink('http://www.cnn.com')">cnn</a></li> <?php $_SESSION['aa'] ='<p id="div1"></p>'; echo $_SESSION['aa']; ?> <form name="input" action="8.php" method="get"><input id="name" name="name" value="<?php echo strip_tags($_SESSION['aa']); ?>" type="hidden"><input type="submit" value="Submit" /></form> Code (markup):