Jump to content

Recommended Posts

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.  :happy-04:

Link to comment
https://forums.phpfreaks.com/topic/293933-select-form-reload/#findComment-1503021
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/293933-select-form-reload/#findComment-1503033
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/293933-select-form-reload/#findComment-1503048
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.