Jump to content

Search the Community

Showing results for tags 'forms in while loop'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hey everyone, I have a page that I created for users to select certain products to reserve. Each product is listed and a form is created using a while loop. For some of the products, the user selects to use it wet or dry using a drop down menu. I also have a javascript function that validates the forms that give the option to select to use the product wet or dry, so that if the user does not select one of these options, a popup will apear prompting them to do so. The problem that I'm having is that ON ALL EXCEPT THE FIRST FORM/PRODUCT PRODUCED FROM THE WHILE LOOP, the form validation produces a popup prompting the user to select the wet or dry option even if the option is selected. THE FIRST FORM VALIDATION ON THE PAGE WORKS AS IT SHOULD. I'm obviously doing something wrong, but I have no idea what. I've worked on it for two days so now I'm asking for help. My code is listed below. Thanks in advance. PHP code: <?php $resultprod = mysql_query("SELECT `inservice`,`prodid`,`prodname` FROM products ORDER BY `order` ASC") or die (mysql_error()); while ($rowprod = mysql_fetch_row($resultprod)) { $inservice = $rowprod[0]; $prodid = $rowprod[1]; $prodname = $rowprod[2]; $resultres = mysql_query("SELECT * FROM reservations WHERE `prodid` = '$prodid' AND `resdate` = '$resdate'") or die (mysql_error()); $checkres = mysql_num_rows($resultres); if ($checkres == 0) { $smallprod = $prodid ."small"; if(substr($prodid,0,2) == 'WD') { echo "<div id='test'>"; echo "<img src='images/$smallprod.jpg' width='470' height='250' border='0' title='Reserve the $prodname now!' />"; echo "<div id='test3'>"; //this is the beginning of the form(s) that I'm having problems with validating echo "<form name='reserve' action='custform.php' method='GET' onsubmit='return validateWetDry()'>"; echo "<select style='height:20px; width:175px; font-size:13px;' name='water'>"; echo "<option value='0' selected>- Choose Wet or Dry -</option>"; echo "<option value='y'>Wet Option</option>"; echo "<option value='n'>Dry Option</option>"; echo "</select><font size='-2'><br /> <br /></font>"; echo "<input type='hidden' name='resdate' value='$resdate' />"; echo "<input type='hidden' name='prodid' value='$prodid' />"; echo "<input type='submit' style='height:30px; width:175px; font-size:14px;' name='submit' value=' Reserve This Unit Now ' />"; echo "</form>"; //this is the end of the form(s) that I'm having problems with validating echo "</div>"; echo "</div>"; } else { echo "<div id='test'>"; echo "<img src='images/$smallprod.jpg' width='470' height='250' border='0' title='Reserve the $prodname now!' />"; echo "<div id='test2'>"; echo "<form name='reserve' action='custform.php' method='GET'>"; echo "<input type='hidden' name='water' value='n' />"; echo "<input type='hidden' name='resdate' value='$resdate' />"; echo "<input type='hidden' name='prodid' value='$prodid' />"; echo "<input type='submit' style='height:30px; width:175px; font-size:14px;' name='submit' value=' Reserve This Unit Now ' />"; echo "</form>"; echo "</div>"; echo "</div>"; } } else { $smallprodres = $prodid . "smallres"; echo "<img src='images/$smallprodres.jpg' width='470' height='250' border='0' title='The $prodname is not available for $resdate' />"; } ?> Javascript Code: function validateWetDry() { var water=document.forms["reserve"]["water"].value if (water==null || water=="0") { alert("Please tell us if you will need to use this unit wet or dry."); return false; } }
×
×
  • 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.