Darkmatter5 Posted October 7, 2008 Share Posted October 7, 2008 Can you call the value of a textbox from outside the form tags? I have a form with a textbox inside it and a PHP script farther down the page, outside the form tag and I am trying to get the value typed into the textbox to display something. But it's not working as if the textbox can't be found. Link to comment https://forums.phpfreaks.com/topic/127453-call-form-objects-outside-the-form-tags/ Share on other sites More sharing options...
F1Fan Posted October 7, 2008 Share Posted October 7, 2008 Try using the ID: document.getElementById('youridhere').value That's JavaScript. If you're using POST or GET, it has to be inside the <form> tags. Link to comment https://forums.phpfreaks.com/topic/127453-call-form-objects-outside-the-form-tags/#findComment-659387 Share on other sites More sharing options...
DarkWater Posted October 7, 2008 Share Posted October 7, 2008 PHP can't magically read things that weren't given to it. If you don't submit the page, the textbox's contents will not be present in the data. Link to comment https://forums.phpfreaks.com/topic/127453-call-form-objects-outside-the-form-tags/#findComment-659390 Share on other sites More sharing options...
Darkmatter5 Posted October 7, 2008 Author Share Posted October 7, 2008 I've gone and modified things a bit, but it's still not working. <table width="304" border="0" cellpadding="2" cellspacing="1"> <form> <th colspan="2" class="style1" align="center">CABINET MAINTENANCE</th> <tr> <td class="style2" align="center" valign="top"> <fieldset class="text_boxes"><legend>ADD A CABINET</legend> <table width="300" border="0" cellpadding="2" cellspacing="1"> <tr> <td width="70" class="required_text" align="left">Name</td> <td width="230"><input name="cab_name" type="text" class="text_boxes" align="left"></td> </tr> <tr> <td align="left">Description</td> <td><input name="cab_description" type="text" class="text_boxes" align="left"></td> </tr> </table> </fieldset> <fieldset class="text_boxes"><legend>EDIT A CABINET</legend> <table width="300" border="0" cellpadding="2" cellspacing="1"> <?php include 'library/config.inc.php'; $conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbnamemain); $query="SELECT cabinet_id, cab_name, cab_description FROM cabinets ORDER BY cab_name ASC"; $result=mysql_query($query) or die ($query. '<br>' .mysql_error()); while(list($cabinet_id, $cab_name, $cab_description)=mysql_fetch_array($result, MYSQL_NUM)) { if(empty($cab_description)) { $cabinet=$cab_name; } else { $cabinet=$cab_name. ": " .$cab_description; } echo "<tr> <td width='200' align='left'>" .substr($cabinet,0,100). "</td> <td width='100' align='center'>edit | <a href='javascript:delCabinet($cabinet_id,$cab_name);'>delete</a></td> </tr>"; } mysql_close($conn); ?> </table> </fieldset> </td> </tr> <tr> <td class="text_boxes" align="left" valign="top">Submission status: <?php $ec->save_cabinet(); ?></td> </tr> <tr> <td class="style2" align="center"> <input name="save_cabinet" type="submit" class="button" value="Submit Cabinet Data" /> <input type="reset" class="button" value="Clear form" /> </td> </tr> </form> </table> Here's the function "save_cabinet()" function save_cabinet() { include 'library/config.inc.php'; $conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbnamemain); if(isset($_POST['save_cabinet'])) { $name=$_POST['cab_name']; $description=$_POST['cab_description']; $creator=$_SESSION['member_id']; mysql_query("INSERT INTO cabinets (cab_name, cab_description, cab_creator)". " VALUES ('$name', '$description', '$creator') ") or die(mysql_error()); echo "Cabinet '$name' added"; } mysql_close($conn); } Please help me figure out why nothing is being processed. Link to comment https://forums.phpfreaks.com/topic/127453-call-form-objects-outside-the-form-tags/#findComment-659411 Share on other sites More sharing options...
F1Fan Posted October 7, 2008 Share Posted October 7, 2008 You're looking for $_POST variables, but you're not using method="post" in your form. Link to comment https://forums.phpfreaks.com/topic/127453-call-form-objects-outside-the-form-tags/#findComment-659419 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.