PDA

View Full Version : How to pass variable?



sdotsen
01-11-2007, 04:39 AM
1) Script Title: Overlapping content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex5/overlapcontent.htm

3) Describe problem:

Let's say I have 10 names listed straight down on a page that's pulled from a mysql table. Next to each name I have an edit button. I would like to be able to click the edit button and the overlap content shows up. It works fine BUT I can't pass the variable into the value in the input type. So, with a little hacking I managed to get it to pass, BUT the input type shows up OUTSIDE the div.

The following works and passes the correct name into the text field. You click on John and "John" shows up in the textbox, you click on Joe and "Joe" shows up in the textbox. You get the idea. However, the textbox shows up OUTSIDE the div, so it's NEVER hidden. If you click the "edit" link, it'll show the div container but there's nothing inside of it except for the text (in this case "Edit Name").


echo "<div id='subcontent'>";
echo "Edit Name";
echo "<form action=''>";
echo "<input type='text' value='$myrow[person_name]' name='dd'>";
echo "<input value='Search' class='topformbutton' type='submit' />";
echo "</form>";
echo "</div>";

So what I ended up doing was throw the code up top outside of my while loop (where the names are generated as they are pulled from the DB). Well, now the textbox shows up inside the div container but I dont know how to pass variables to it. I tried setting a variable before the while loop ends, but what ended up happening is, it picks up the LAST record that was pull. So for each 10 records, everytime you go click "Edit" the name "Greg" shows up (Greg being the last record it pulled).

So, if I can figure out how to have it dynamically populate the textbox, I would be so happy!