|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
2 Forms in 1 page
Hello everyone,
newbie question: is it possible to use the value of a dropbox form (from 'SELECT') in 2 different submit forms? I have a page that consists of 'SEARCH' form and 'ADD' form and a dropdown SELECT a database menu form. I would like to use the value of selected database from a dropdow menu to process both forms. If SEARCH form is press it will check entry for a 'KEYWORD' and the SELECTED database, but if 'ADD' is pressed it will only check the SELECTED database and redirect the page to another page. Error: the SELECTED database is not being pass when I click on the 'ADD' button. =====below is how i tried to implement it, please check ==== php Code:
|
|
#2
|
|||
|
|||
|
RE: 2 Forms in 1 page
Only the information form that is submitted is sent to the next page. What you would need to do is use javascript to assign the selected db to a hidden field in the second form. a couple things you need to remember, is that
1. you must give each of the forms a different name. 2. Check to make sure that the selected db hidden field in the second form contains a value before running your query us an onChange event in the dropdown to trigger the population of the hidden field in the second form |
|
#3
|
|||
|
|||
|
RE: 2 Forms in 1 page
helo thanks for the reply...
is there a way to implement this without using javascript since i haven't come across javascripting at all. again, thanks for the reply. |
|
#4
|
|||
|
|||
|
RE: 2 Forms in 1 page
Really the only way to accomplish this is with JavaScript! you would need to use an onChange event in the select box that set the value of a hidden field in the second form.
try doing a little research and if you need some assistance at that point let me know. search for Javascript onChange events using SELECT Boxes |
|
#5
|
|||
|
|||
|
RE: 2 Forms in 1 page
hi Blindeddie,
i have modified my form but still needs the functionality i mentioned in my first post. this time the page has submit buttons for add/update/delete/reset that i would like to assign 'action' according to its function. as i have zero knowledge in javascript and just starting to learn php could please guide me on how to implement your suggestion. please find below my php script for the page, at the last part of the scri[t where it used 'isset' fucntion is the suggestion that i got from other group which currentlt the doesnt work. thanks again for your reply. [highlight=php] <?php //edit form for pc database $z = $_GET['x']; include ("conn_inc.php"); $query = "select * from pc where pcnum = '$z'"; $mysql_result=mysql_query($query,$conn); $pc=mysql_fetch_array($mysql_result); mysql_close($conn); ?> <html> <head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table align = "center" border="1" cellpadding="2" cellspacing="0"> <tr> <td align="center" colspan="2">POINT CODE EDIT FORM</td> </tr> <br> <br> <tr> <td>Node Site</td> <td> <?php echo "<input type="text" name="nodesite" value="". $pc['nodesite']; echo "">"; ?> </td> </tr> <tr> <td>Node Type</td> <td> <?php echo "<input type="text" name="nodetype" value="". $pc['nodetype']; echo "">"; ?> </td> </tr> <tr> <td>Node Site</td> <td> <?php echo "<input type="text" name="nodeclli" value="". $pc['nodeclli']; echo "">"; ?> </td> </tr> <tr> <td>ANSI Format</td> <td> <?php echo "<input type="text" name="ansi" value="". $pc['ansi']; echo "">"; ?> </td> </tr> <tr> <td>CCITT Format</td> <td> <?php echo "<input type="text" name="ccitt" value="". $pc['ccitt']; echo "">"; ?> </td> </tr> <tr> <td>HEX Format</td> <td> <?php echo "<input type="text" name="hex" value="". $pc['hex']; echo "">"; ?> </td> </tr> <tr> <td>Comments</td> <td> <?php echo "<input type="text" name="comments" value="". $pc['comments']; echo "">"; ?> </td> </tr> <tr> <td align="center" colspan="2"> <input type=submit name="add" value="Add" > <input type=submit name="delete" value="Delete" > <input type=submit name="update" value="Update" > <input type=reset name="clear" value="Clear" > </td> </tr> </form> <?php if (isset($POST['add'])) { echo "database will be added"; } if (isset($POST['delete'])) { echo "database will be deleted"; } if (isset($POST['update'])) { echo "database will be updated"; } ?> </body> </head> </html> |
|
#6
|
|||
|
|||
|
RE: 2 Forms in 1 page
hello,
this seems to be working now, i made an syntax error in the script. [highlight=php] if (isset($POST['add'])) { echo "database will be added"; } shld be if (isset($_POST['add'])) { echo "database will be added"; } [highlight=php] |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > 2 Forms in 1 page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|