The following warnings occurred: | ||||||||||||||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Form dropdown list - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26) +--- Thread: Form dropdown list (/showthread.php?tid=702) Pages:
1
2
|
Form dropdown list - pierre - 08-30-2017 Hi I would like to have a dropdown list in a form in US 4.2.9. How can I create this? Is it as simple as using HTML select? Keep in mind I don't have any PHP knowledge. Thanks Pierre Form dropdown list - Brandin - 08-30-2017 You got it! Simple as an HTML Select. Similar to a name or ID for a input of text, it will only take the value you select as the value for this input. Let me know if you have any questions. Form dropdown list - mudmin - 08-30-2017 Yep. If you need help, don't be afraid to ask. Also, since you're new, you'll probably want this primer on using Php to work with the database. https://youtu.be/rb0kD5tCENM Form dropdown list - pierre - 08-31-2017 Great, thanks mudmin. Form dropdown list - pierre - 08-31-2017 I'm afraid I'm getting stuck. Here's where I am: <label for="street">Residential address* (e.g. 1)</label> <SELECT class="form-control" name="streetlist" form="payment-form"> <option value=""></option> <option value="Street1">1</option> <option value="Street2">2</option> </SELECT> <input class="form-control" maxlength="13" type="text" name="street" id="street" value="<?php if (!$form_valid && !empty($_POST)){ echo $street;} ?>" required > I made the 1st <option> blank as an attempt to have the person select a street instead of leaving it at default. The page still displays the original input field AND now a select box. So I remove the <input> section leaving: <label for="street">Residential address* (e.g. 1)</label> <SELECT class="form-control" name="streetlist" form="payment-form"> <option value=""></option> <option value="Street1">1</option> <option value="Street2">2</option> </SELECT> Now I've lost the php required validation. Some more messing around and found this to work: <label for="street">Residential address* (e.g. 1 Douglas Carr)</label> <SELECT class="form-control" name="streetlist" form="payment-form" value="<?php if (!$form_valid && !empty($_POST)){ echo $street;} ?>" required > <SELECT class="form-control" name="streetlist" form="payment-form"> <option value=""></option> <option value="Street1">1</option> <option value="Street2">2</option> </SELECT> Problem solved. Happiness. Well, almost Form dropdown list - pierre - 08-31-2017 OK, problem not solved. On testing my solution above: <label for=”street”>Residential address* (e.g. 1 Douglas Carr)</label> <SELECT class=”form-control” name=”streetlist” form=”payment-form” value=”<?php if (!$form_valid && !empty($_POST)){ echo $street;} ?>” required > <SELECT class=”form-control” name=”streetlist” form=”payment-form”> <option value=””></option> <option value=”Street1″>1</option> <option value=”Street2″>2</option> </SELECT> I now get error "Street is required". This is presumably because the php required check is before the <select>. I'm in your hands, folks - how to get the <select> to work with validation? I will need the exact code I think. Thanks! Form dropdown list - Brandin - 08-31-2017 One thing you should do is add the "required" attribute to your select: Code: <select class="form-control" name="streetlist" form="payment-form" required > Your validation imo should just be required, like this: http://pasted.co/31fbd8f5 Form dropdown list - pierre - 08-31-2017 Thanks Brandin but that did not do the trick. I added a couple of fields to users/views/_join.php Added these fields in users/join.php as well. I pasted users/join.php here http://pasted.co/71955765 users/views/_join.php here http://pasted.co/5779c6fa Thanks for your help so far! Form dropdown list - pierre - 08-31-2017 As a test I commented out the <select> and reverted to the <input>. That works. So the problem is only with the <select> portion. Form dropdown list - Brandin - 08-31-2017 Your issue is that you did call the inputs in your post Right after the post opens you see things like Code: $username = Input::get('username') |