Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a variable

Status
Not open for further replies.

ndog4ever

MIS
Feb 6, 2002
92
US
i have the following drop down menu for a router/interface selection. Whenever i choose an interface, i need to have a submit button that passes what i choose. I have tried various ways but no luck. Does anyone have a suggestion on where to place a submit button inside this form, or do i need to start a new form?

thanks

//returns an array of table names
function getTables(){
$table_array = array();
$table_list = mysql_list_tables($this->db);
while(list($bla)=mysql_fetch_array (table_list)){
array_push($table_array, $bla);
}
return $table_array;
}
//returns formatted SELECT portion of a HTML FORM
function getSelect(){
$table_array = $this->getTables();
echo &quot;<FORM METHOD=POST NAME=\&quot;tableform\&quot;>&quot;;
echo &quot;<SELECT NAME=\&quot;tables\&quot;>&quot;;
for($i=0; $i < count($table_array); $i++){
echo &quot;<OPTION value=&quot;.$table_array[$i].&quot;>&quot;.$table_array[$i];
}
echo &quot;</SELECT>

</FORM>&quot;;
}
 
Try adding something like:

<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;SUBMIT&quot;>

before the &quot;</FORM>&quot; line
 
i added the following text after the </FORM> and it works sorta.

echo &quot;<FORM METHOD=POST ACTION=\&quot;field.php\&quot;>&quot;;
echo &quot;<input type=submit name=\&quot;submit\&quot; value=submit>&quot;;
echo &quot;</FORM>&quot;;

What I am wondering is when I click the submit button, is the proper value being passed over to field.php? I am confused in passing the value that I select in the drop down menu. Thanks for the help so far.
 
//returns formatted SELECT portion of a HTML FORM
function getSelect(){
$table_array = $this->getTables();
echo &quot;<FORM METHOD=POST NAME=\&quot;tableform\&quot;>&quot;;
echo &quot;<SELECT NAME=\&quot;tables\&quot;>&quot;;
for($i=0; $i < count($table_array); $i++){
echo &quot;<OPTION value=&quot;.$table_array[$i].&quot;>&quot;.$table_array[$i];
}
echo &quot;</SELECT>
echo &quot;<input type=submit name=submit value=submit>&quot;;
</FORM>&quot;;
}

// for testing to check if its actually passing anything to the proper page, changer the METHOD from POST to GET and all will be revealed in the URL. ***************************************
Party on, dudes!
[cannon]
 
Its starting to make more sense now, but when i click the submit button, it just reloads the page. What I am wondering is can i just add another form method to make it jump to another PHP page so i can pass that variable to an array of some sort to display the information on the particular router/interface card??

thanks

i added this so far, but i think im wrong

echo &quot;</SELECT>&quot;;
echo&quot;<FORM METHOD=POSTACTION=\&quot;field.php\&quot;>&quot;;
echo &quot;<input type=submit name=submit value=submit>&quot;;
echo &quot;</FORM>&quot;;
 
well if you do something like (and this is VERY ROUGH.

<?php
if (!$submit){ // no submit so we display the form
echo &quot;<form .. blah
echo &quot;<input blah submit...
echo &quot;</form...

} else{ //submit has been hit so work on data
echo &quot;$ all your variables here
}
?>

or create a new page and access it from METHOD=post action=new_page.php

As I wrote that I noticed you have a typo ..

echo&quot;<FORM METHOD=POSTACTION=\&quot;field.php\&quot;>&quot;;
you need a space between POST and ACTION ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top