tycy Posted January 15, 2015 Share Posted January 15, 2015 Can someone help me with a code , which can make a select form to reload the page or the form in the moment when a option from it , is been selected. i try it whit onClick="document.location.reload()"; but doesn't work properly. thx Quote Link to comment https://forums.phpfreaks.com/topic/293933-select-form-reload/ Share on other sites More sharing options...
cyberRobot Posted January 15, 2015 Share Posted January 15, 2015 Could you provide a little more information about what "doesn't work properly" means? Is it not working at all? Or if it doesn't work as expected, what does it currently do and what do you expect it to do? Also, it may help to see more code. Especially the code where you've applied the onclick attribute. Perhaps you are already aware of this, but please surround the code with tags. It will make your code and post easier to follow. Quote Link to comment https://forums.phpfreaks.com/topic/293933-select-form-reload/#findComment-1503021 Share on other sites More sharing options...
tycy Posted January 15, 2015 Author Share Posted January 15, 2015 Well actualy what i want to do is. I have a Select from db which in case the DB contain information.the script will create a Select Form.And when i will use the select option , i can UPDATE my desire info. in a few words,it's 3 Input texts + Select Form , when i choose one option from select and fill up those 3 inputs , some things from my site will be updated. What i'm try to do is , to display the info from db in the Value option of the input fields when i choose one option from select. But i realize it's little bit complicated to do this, i thought will work with onclick or onload option and some changes on the php code , but is not that simple. $sql = "SELECT * FROM welcome"; $rows = $conn->sqlExec($sql); $nr_row = $conn->num_rows; $pag .=' <span class="styleform"><h4>Edit About Section !</h4></span> <br /> <script type="text/javascript" src="checkjs/welcome.js"></script> <form method="post" action="aboutsend.php" onsubmit="return checkForm(this)";> <table border="0" cellspacing="0" cellpadding="1" style="border:1px solid #888888; padding:1px;"> <tr><td><span class="styleform">Select Paragraph:</span></td><td> <select name="paragraphs" id="paragraphs"> <option>Select Paragraph</option> '; foreach($rows as $row) { $pag .='<option value="'.$row['id'].'" >Paragraph '.$row['id'].'</option>'; } $pag .=' </select> </td></tr> <tr><td><span class="styleform">Principal Title About Us :</span></td><td><input type="text" name="sttitle" id="sttitle" size="50" /></td></tr> <tr><td><span class="styleform">Secont Title About Us :</span></td><td><input type="text" name="sectitle" id="sectitle" size="50" /></td></tr> <tr><td><span class="styleform">Content About Us :</span></td> <td><textarea name="content" id="content" rows="7" cols="52"></textarea></td></tr> <tr><td><span class="styleform">Edit About Us:</span></td><td><input type="submit" name="updwelcome" value="Edit Info" /></td></tr> </table> </form> The code is this one.is the old code , i give up to continue this task. I just think could works if i make a select with all info , i put them intro array and with some js code to fill up the inputs , like onload Paragraph 1 display the array ..but i don't have enaught knowledges about js or ajax Quote Link to comment https://forums.phpfreaks.com/topic/293933-select-form-reload/#findComment-1503033 Share on other sites More sharing options...
cyberRobot Posted January 15, 2015 Share Posted January 15, 2015 So basically, it sounds like you're trying to populate the three input fields based on the selection made in the "paragraphs" drop down. If that's the case, you shouldn't need to reload the page or form. The following link shows how to populate a second form drop down based on a selection made in the first one: http://www.dyn-web.com/tutorials/forms/select/paired.php Of course, you would need to figure out how to adapt the code to work with text input fields. As for using the drop-down selection to query a database, you could look into using AJAX to contact the server. Or you could look into pre-loading the information into your JavaScript code so that it can be accessed whenever the drop-down menu is changed. Quote Link to comment https://forums.phpfreaks.com/topic/293933-select-form-reload/#findComment-1503048 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.