Results 1 to 2 of 2

Thread: Required Attribute for Select Option - For PHP WordPress File

  1. #1
    Join Date
    Feb 2010
    Location
    Ireland
    Posts
    23
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Required Attribute for Select Option - For PHP WordPress File

    Hi there,

    I hope I am posting in the correct forum here as I am working on a WordPress site so I am working between PHP and HTML.

    I sell cards and I am currently trying to get them online. You can see the link here: http:/little-letters.com/?wpsc-product=baby-blue-baby-boy-thankyou-card

    My problem is I don't know how to make the dropdown boxes a requirement before the form can be submitted. At the moment you can select no options and it still adds the product to the cart.

    I have been looking at this part of the PHP file within WordPress - perhaps it could be another file? I am more used to HTML and CSS.

    PHP Code:
    <?php
                            
    /**
                             * Form data
                             */
                            
    ?>
                          <div class="section_rt">
                            <form class="product_form" enctype="multipart/form-data" action="<?php echo esc_urlwpsc_this_page_url() ); ?>" method="post" name="1" id="product_<?php echo wpsc_the_product_id(); ?>">
                                <?php do_action 'wpsc_product_form_fields_begin' ); ?>
                                <?php if ( wpsc_product_has_personal_text() ) : ?>
                                    <fieldset class="custom_text">
                                        <legend style="font-family:Georgia; font-style: italic; font-size: 18px;"><?php _e'Your Info''wpsc' ); ?></legend>
                                        <p style="font-family:Trebuchet MS;  font-size: 12px;"><?php _e'Name, DOB, Weight etc''wpsc' ); ?></p>
                                        <textarea cols='55' rows='5' placeholder="Name, Date of Birth, Weight" style='width:130px; resize: none; margin-bottom:20px;' name="custom_text"></textarea>
                                    </fieldset>
                                <?php endif; ?>

                                <?php if ( wpsc_product_has_supplied_file() ) : ?>

                                    <fieldset class="custom_file">
                                        <legend style="font-family:Georgia; font-style: italic; font-size: 18px;"><?php _e'Your Photo''wpsc' ); ?></legend>
                                        <p style="font-family:Trebuchet MS;  font-size: 12px;"><?php _e'Choose a photo''wpsc' ); ?></p>
                                        <input type="file" name="custom_file" />
                                    </fieldset>
                                <?php endif; ?>
                            <?php /** the variation group HTML and loop */?>
                            <?php if (wpsc_have_variation_groups()) { ?>
                            <fieldset style="border:0;"><legend style="font-family:Georgia; font-style: italic; font-size: 19px; color:#404040;"><?php _e('Options''wpsc'); ?></legend>
                            <div class="wpsc_variation_forms">
                                <table style="border:0;">
                                <?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
                                    <tr><td class="col1"  style="border:0;"><label style="font-family:Trebuchet MS;  font-size: 12px;" for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label></td>
                                    <?php /** the variation HTML and loop */?>
                                    <td class="col2"><select style="font-size:12px; width:120px;" class="wpsc_select_variation" name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>">
                                    <?php while (wpsc_have_variations()) : wpsc_the_variation(); ?>
                                        <option style="font-family:Trebuchet MS;  font-size: 12px; padding:10px;" value="<?php echo wpsc_the_variation_id(); ?><?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option>
                                    <?php endwhile; ?>
                                    </select></td></tr>
                                <?php endwhile; ?>
                                </table>
                            </div><!--close wpsc_variation_forms-->
                            </fieldset>

    If anyone has any ideas I would greatly appreciate it! I have tried adding in "required" as you would do with HTML but to no avail.

    Thanks in advance!

  2. #2
    Join Date
    Feb 2010
    Location
    Ireland
    Posts
    23
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Anyone any ideas?

Similar Threads

  1. [Project] Custom Wordpress Theme Required!
    By bbilal in forum General Paid Work Requests
    Replies: 2
    Last Post: 05-08-2014, 05:45 AM
  2. Required field on menu select
    By nate51 in forum JavaScript
    Replies: 2
    Last Post: 09-01-2011, 01:12 PM
  3. using IF in Select Option
    By taz in forum ASP
    Replies: 1
    Last Post: 04-26-2010, 02:59 PM
  4. Select option drop down
    By cblake843 in forum JavaScript
    Replies: 4
    Last Post: 04-24-2006, 02:54 PM
  5. Populate option of <select>
    By d4d4ng in forum JavaScript
    Replies: 2
    Last Post: 04-10-2006, 02:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •