Jump to content

Recommended Posts

Hi,

 

I'm creating a form in which I need to do the following:

 

I have a select box in which I have some sale categories.  Some of these categories are 'locked', in other words, no more items should be added to that sale.

 

I need to create an 'override' section to the form to expand if a locked sale is selected, without reloading the page (complications due to POST).  Having no clue about ajax, and having trawled the web for the last couple of days, I need some help!!

 

Here is the php code on which I need to base this:

 

<tr>
	<td>Sale Number: <?php echo $rcatinfo; ?></td>
	<td>
            <select name="salenum">
		<!--<option value='none'>-- Select A Sale --</option>-->
			<?php
				do {

						if ($rcatinfo==$row_selectsalenum['id']) {
							echo "<option  value ='".$row_selectsalenum['id']."' selected>".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']."</option>\n";
						} else {
							echo "<option value ='".$row_selectsalenum['id']."'>".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']."</option>\n";
						}

					} while ($row_selectsalenum = mysql_fetch_assoc($resultsalenum));

						$rows = mysql_num_rows($resultsalenum);
						if($rows > 0) {
						mysql_data_seek($resultname, 0);
						$row_selectsalenum = mysql_fetch_assoc($resultsalenum);

						}
			?>
	</select>
	</td>
</tr>

 

I have set up a 'locked' column in the table and can add this to the select list, but am stuck as to how to proceed in order to create a form (which isn't a problem) if the category is locked...

 

Any ideas would be appreciated.

 

TIA

I'm having trouble understanding your problem.  I get the jist, but I think you need to break it down.

Also, and example/link to your site might help.

 

First, you're saying simply that when someone selects a locked item from the select list, you want something to pop down near it, allowing an override?  What type of thing needs to appear.. where.. etc?

 

Secondly, depending how you want to do it, you could have the PHP output a custom attribute to the select if it is locked, and have javascript read that accordingly.  Ex:

<?php
  if($row['isLocked'] == 1){
    echo '<option value="'.$row['id'].'" locked="true">'. //etc etc
}
?>

 

And then your <select > tag would have the onchange() function call javascript to see whether it needs to produce the additional form override....

 

Anything else, you'll have to be a lot more specific about what's not working, and what code you have, and why it's not working...

Hi,

 

Sorry for the delay in replying - caught a nice bout of flu over the weekend, so I'm a little behind on work :(

 

First, you're saying simply that when someone selects a locked item from the select list, you want something to pop down near it, allowing an override?  What type of thing needs to appear.. where.. etc?

 

Exactly.  I want a checkbox and a text input box.  These will appear directly below the select, and I can separate the tables up if necessary.  Unfortunately, the code is for a private adminisatration project, so it's not on the web as such.

 

I just don't understand enough about Javascript to know how to make a form element 'appear'.

 

Going back to your sample, I assume I am right in adding the 'locked' element like this:

 

<tr>
      <td>Sale Number: <?php echo $rcatinfo; ?></td>
      <td>
            <select name="salenum" onchange="show.hiddenForm(locked)">
         <!--<option value='none'>-- Select A Sale --</option>-->
            <?php
               do {

                     if ($rcatinfo==$row_selectsalenum['id']) {
                        echo "<option  value ='".$row_selectsalenum['id']."' selected";
  if($row['isLocked'] == 1){
    echo 'locked="true"'. //etc etc
}
echo ">".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']."</option>\n";
                     } else {
                        echo "<option value ='".$row_selectsalenum['id']."'";
  if($row['isLocked'] == 1){
    echo 'locked="true"'. //etc etc
}
echo ">".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']."</option>\n";
                     }

                  } while ($row_selectsalenum = mysql_fetch_assoc($resultsalenum));

                     $rows = mysql_num_rows($resultsalenum);
                     if($rows > 0) {
                     mysql_data_seek($resultname, 0);
                     $row_selectsalenum = mysql_fetch_assoc($resultsalenum);

                     }
            ?>
      </select>
      </td>
</tr>

 

Yeah?

 

Thanks for understanding.

Right - got the select to show if the item is locked, now I've just gotta figure out how to show the form element when a locked sale is selected.  I've made it a bit obvious at the moment to show which sale is locked...

 

    <?php
        // FIXME - add selection of option if sale locked.
        
    ?>
	<td>Sale Number: <?php echo $rcatinfo; ?></td>
	<td>
            <select name="salenum" onchange="">
		<!--<option value='none'>-- Select A Sale --</option>-->
			<?php
    				do {
						if ($rcatinfo==$row_selectsalenum['id']) {
							echo "<option  value ='".$row_selectsalenum['id']."' selected>".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']." - ".$row_selectsalenum['locked'];
                                if ($row_selectsalenum['locked'] == 1) {
                                    echo "LOCKED";
                                }
                                echo "</option>\n";
						} else {
							echo "<option value ='".$row_selectsalenum['id']."'>".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']." - ".$row_selectsalenum['locked'];
                                if ($row_selectsalenum['locked'] == 1) {
                                    echo "LOCKED";
                                }

                                echo "</option>\n";
						}

					} while ($row_selectsalenum = mysql_fetch_assoc($resultsalenum));

						$rows = mysql_num_rows($resultsalenum);
						if($rows > 0) {
						mysql_data_seek($resultname, 0);
						$row_selectsalenum = mysql_fetch_assoc($resultsalenum);

						}
			?>
	</select>
	</td>
</tr>
<?php
  if ($sale_locked == 1) {
      echo "<tr><td colspan='2'>";
      echo "<span style='color:#ff0000'>This sale has been sent to publication as a catalogue.</span>";
      echo "</td></tr>";
      echo "<tr><td>";
      echo "Assigned Lot Number: ";
      echo "</td><td>";
      echo "<input type='text' name='wibble' value='".$rlot_num."' readonly size='10' />";
      echo "</td></tr>";
      // FIXME - add feature for when adding the lots to consignment, if it's a locked sale.

  }


?>

 

See also attached image for output.  I'd like the extra form to appear directly below this select....  ???  Thanks

 

[attachment deleted by admin]

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.