argrafic Posted January 11, 2008 Share Posted January 11, 2008 Hello to all, I have a form that has a textfield that will enable/disable depending on an option of a menu/list. The problem I have is that when the textfield is disabled it "disappears" from the form and then when I try to insert it to MySQL I get the error "Undefined index:" of the form field of the disabled textfield. How can I POST even if it's disabled? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/85539-solved-problem-with-inserting-into-db-a-disabled-field/ Share on other sites More sharing options...
twostars Posted January 11, 2008 Share Posted January 11, 2008 Hello to all, I have a form that has a textfield that will enable/disable depending on an option of a menu/list. The problem I have is that when the textfield is disabled it "disappears" from the form and then when I try to insert it to MySQL I get the error "Undefined index:" of the form field of the disabled textfield. How can I POST even if it's disabled? Thanks! Post (not intentional wording) the form, and PHP side of it. Quote Link to comment https://forums.phpfreaks.com/topic/85539-solved-problem-with-inserting-into-db-a-disabled-field/#findComment-436505 Share on other sites More sharing options...
chronister Posted January 11, 2008 Share Posted January 11, 2008 When a form field is disabled, it does not send it's value to the next page. take a look at the following. <?php foreach($_POST as $k=>$v) { echo $k .' -- '. $v; } ?> <form id="form1" name="form1" method="post" action=""> <p> <input type="text" name="textfield" value="test value" disabled="disabled" /> </p> <p> <input type="submit" name="Submit" value="Submit" /> </p> </form> The text field will not post to the next page. The submit button does, but the text box does not. I am not sure what to tell you except maybe use a hidden field to store the value that your disabled field has. Nate Quote Link to comment https://forums.phpfreaks.com/topic/85539-solved-problem-with-inserting-into-db-a-disabled-field/#findComment-436543 Share on other sites More sharing options...
argrafic Posted January 14, 2008 Author Share Posted January 14, 2008 i used a hidden field that would recieve the value of the enabled/disables field with an "onChange" event. then, i would have the field available for the database. again, thanks!!!! Quote Link to comment https://forums.phpfreaks.com/topic/85539-solved-problem-with-inserting-into-db-a-disabled-field/#findComment-439314 Share on other sites More sharing options...
Pancake Posted January 15, 2008 Share Posted January 15, 2008 And crafty users can change hidden form fields and disabled fields, so treat hidden/disabled fields as if they were not hidden/disabled Quote Link to comment https://forums.phpfreaks.com/topic/85539-solved-problem-with-inserting-into-db-a-disabled-field/#findComment-439370 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.