Jump to content

Pass select menu results to a form field


meresda

Recommended Posts

Bit of a programming newb, so be nice :)

 

I am developing a small app in Joomla! where I need to sequentially number file folders. On the page where I add new folders I have a select menu to select the type of folder. In this case, either Action, Reference, or Archive. What I want to have happen is after I select the type of folder, I want to enter the next available number in the form field. I realize to do this without resubmitting the page I need to use javascript and onchange. The problem is I am almost clueless when it comes to javascript (I am working on it though) so I need some help. This is what I have.

<fieldset class="adminform">
<legend><?php echo JText::_( 'Folders' ); ?></legend>
      <table class="admintable">
      <tbody>
      <tr>
        <td width="20%" class="key"><label for="Type"><?php echo JText::_( 'Folder Type' ); ?>:</label>
        </td>
      <td><?php echo $lists['FolderType'];?></td>
      </tr>
      <tr>
        <td width="20%" class="key"><label for="FolderNumber"><?php echo JText::_( 'Folder Number' ); ?></label>
        </td>
        <td><INPUT type="text" name="FolderNumber" id="FolderNumber" value="<?php echo $row->FolderNumber;?>"></td>
      </tr>
      <tr>
        <td width="20%" class="key"><label for="Location"><?php echo JText::_( 'Location' ); ?></label>
        </td>
        <td><?php echo $lists['Location']?></td>
        <td></td>
      </tr>
      <tr>
        <td width="20%" class="key"><label for="MaxFiles"><?php echo JText::_( 'Max Files' ); ?></label>
        </td>
        <td><INPUT type="text" name="MaxFiles" id="MaxFiles" value="<?php echo $row->MaxFiles;?>"></td>
      </tr>
      </tbody>
      </table>
      </fieldset>

I have the last folder numbers entered for each type of file folder stored in an array $foldernumbers. My select menu looks like this.

<select name="FolderType" id="FolderType" class="inputbox" ><option value="-1" >Select a Folder Type</option>
<option value="0" >Action</option>
<option value="1" >Reference</option>
<option value="2" >Archive</option>
</select>

 

I assume I have to pass my php array into a javascript array then call that based on my select menu. Only I have no clue how to go about doing that.

 

Thanks in advance for any assistance.

Mike

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.