web_master Posted January 11, 2013 Share Posted January 11, 2013 Hi, I walt to use a two diffferent form tags with same name. This is a slect tag and input (text) tag. But I dont know how can I do do that. Why? Because if something cant find in selecton to add in "input" tag. Is that posibble somehow? <fieldset class="input_form"> <legend>Már bevitt zeneszámok listázása:</legend> <?php $QueryReturn_selected = mysql_query(' SELECT * FROM `zeneszamok` WHERE `zeneszamok_id` = "' . $zene_id . '" '); if(!$QueryReturn_selected){ echo mysql_error(); exit; } $request_selected = mysql_fetch_array($QueryReturn_selected); if($request_selected['zeneszamok_id']) { $selected_id = $request_selected['zeneszamok_id']; $selected_view = $request_selected['zeneszamok_zeneszam']; } else { $selected_id = '0'; $selected_view = 'Válassz egy már beírt zeneszámot'; } ?> <article><select name="zeneszamok_zeneszam"> <option selected="selected" value="<?php echo $selected_id;?>"><?php echo $selected_view;?></option> <?php $QueryReturn_select = mysql_query(' SELECT * FROM `zeneszamok` WHERE `zeneszamok_datum` = "' . $datum . '" '); if(!$QueryReturn_select){ echo mysql_error(); exit; } while($request_select = mysql_fetch_array($QueryReturn_select)) { ?> <option value="<?php echo $request_select['zeneszamok_id'];?>"><?php echo $request_select['zeneszamok_zeneszam'];?></option> <?php }?> </select></article> </fieldset> </article> <article style="height: 20px;"><!-- distancer --></article> <!-- UJ ZENESZAM --> <article id="auto"> <fieldset class="input_form"> <legend>Új zeneszám bevitele:</legend> <input style="width: 98%;" type="text" id="zeneszamok_zeneszam" name="zeneszamok_zeneszam" value="<?php echo $vanezeneszam;?>" /> </fieldset> </article> <!-- END UJ ZENESZAM --> on simplest way: <select name="name"> <option selected="selected"></option> <option></option> </select> <input type="text" name="name" /> Quote Link to comment https://forums.phpfreaks.com/topic/273021-select-and-input-form-tag-with-same-name/ Share on other sites More sharing options...
Barand Posted January 11, 2013 Share Posted January 11, 2013 Whichever comes later in the form is the one that will be passed in $_POST['name'], even if it is empty. There is no need for them to have the same name to do what you want to do. Use the one that isn't blank. If both are none blank then you have decide which has priority, or treat as an error Maybe even do something client-side in javascript to clear and prevent entry in the text box if a selection has been made. Quote Link to comment https://forums.phpfreaks.com/topic/273021-select-and-input-form-tag-with-same-name/#findComment-1404992 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.