Page 1 of 1

cant get value

Posted: Mon Jan 10, 2011 1:45 am
by madu
Hi friends,,,,
just look the following code,,,

//Fir.php

Code: Select all

<html>
<head>
<title>Group box</title>
<?php
 	include "tacre.php";
	echo '<script language=javascript>
	function add()
  		{
                 var str=document.getElementById("txt").value;		 
		 var k =document.createElement("option"); 		
		document.getElementById("cr").options.add(k);		
		 k.text=str;
		 		 
		 alert(str);                  
		var lastvalue = document.getElementById("cr").options[document.getElementById("cr").options.length-1].value;
                alert("last " + lastvalue);
  	        }

</script>';
?>
</head>
<body>
<div style="position:absolute;left:10px;top:100px">
<form name=fr action=gm.php>
Enter the Group name <br>You want to create: 
<input type=text id=txt name=txt style="position:absolute;left:150px;top:10px" ><br>
<select id=cr name=sel style="position:absolute;left:350px;top:10px" >
<option>None</none>
</select><br>
<input type=submit onClick="add();" name =cre value=Create style="position:absolute;left:150px;"  >
</form>
</div>
</body>
</html>
//gm.php

Code: Select all

<?php
$last=$_POST['txt'];
echo $last;
?>
After executing the fir.php if see the url address the "txt" value would be our given value,,,, but echo statement print nothing,,,, wat s the prob,,,,

Re: cant get value

Posted: Mon Jan 10, 2011 1:47 am
by Benjamin
:arrow: Use

Code: Select all

 tags when posting code in the forums.

Re: cant get value

Posted: Mon Jan 10, 2011 4:02 am
by madu
got answer,,,,,,