cant get value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
madu
Forum Commoner
Posts: 32
Joined: Sat Dec 25, 2010 3:19 am
Location: india

cant get value

Post 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,,,,
Last edited by Benjamin on Mon Jan 10, 2011 1:46 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: cant get value

Post by Benjamin »

:arrow: Use

Code: Select all

 tags when posting code in the forums.
madu
Forum Commoner
Posts: 32
Joined: Sat Dec 25, 2010 3:19 am
Location: india

Re: cant get value

Post by madu »

got answer,,,,,,
Post Reply