Jump to content

Update form


aeroswat

Recommended Posts

Here is my predicament. I have a list box on the left side of my form that holds a list of system names and on the right side are some control boxes that should pertain to information associated with each system. I am trying to get help on how I should go about solving the following problem:

 

Whenever you click the system on the left side I want it to update the control boxes on the right side to display the information associated with the selected school system. Furthermore I want this to be a form that I can edit so I can make any changes that I need to and then hit the submit button to change the information for that system.

 

I understand that this will require Javascript and PHP most likely. Any ideas on how I could set this up?

Link to comment
Share on other sites

You would need to set an onchange listener on <select> and then manipulate the other values when that change event is triggered.

 

Do you plan to just load in a couple of predefined 'settings'  on the 'right side' or do you intend to alter the entire structure of the form?

 

Say on the left you have

<select>
  <option>Cars</options>
  <option>Bikes</option>
</select>

 

and the right would be (semi pseudo code)..

<label>Color:</label>
<select>
  <option>Red</option>
  <option>Green</option>
</select>

Do you want to do something like add a third color 'Yellow' when Cars is selected or do you want to do something like add a checkbox "Spare tire".

 

The latter could be quite a bit of work on PHP side with a lot of if( isset($_POST['whatever']) ) checks and would probably be easier if you simply had separate forms (if possible) instead of one big magic do-it-all form.

Link to comment
Share on other sites

They are pre-defined controls. I think this might have to be the way I do it although it seems rather sloppy to me. I have a list of school systems on the side. Each school system is assigned a Region #, Account #, and name. When you click the school system in the box I want to be able to show the region/acct/name on the side and have that part editable. So if they have a certain school selected and they change the name and click submit then I want it to update the database (the easy part). What I'm going to have to do until I get a better solution is the following:

 

Populate the list box

Trigger a javascript function in the onchange event

That function will use the ajax function to call a php file

That php file will send back a comma delimited list for what should be filled in the boxes

The javascript will break apart that list and fill in each appropriate control with the value from the delimited list.

Link to comment
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.