Jump to content

mckeegan375

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mckeegan375's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for all your help guys! Joe, i used the link you posted for my solution Cheers Andy
  2. Hi All! I was hoping someone could help me with some simple JS form validation which involves a loop. So far, i have the following: <SCRIPT language=JavaScript> function validateForm() { var a = document.getElementsById('totalpayment'); var b = document.getElementsById('netpay'); for(var k=0;k<b.length;k++){ var c = a[k] var d = b[k] if (c.value > d.value) { alert("Total payment cannot be greater than net pay"); return false; } } } </script> My form has a loop which pulls data from a mysql database and it contains the fields 'totalpayment' and 'netpay' yet the validation does not display the alert if the total payment entered is greater than the net pay. Any help would be much appreciated. Cheers Andy
  3. Thanks for the help guys, i used requinix's solution in the end. Cheers Andy
  4. Hi All Was hoping someone could help me with a little validation problem. On my webpage, i have a form which has two date fields which are made of 3 drop down boxes each (DD, MM and YYYY). I am trying to make it so that a javascript message alert appears if the start date entered is before the end date but im not sure how to do it. Is there a way i can take my 3 date dropdown values and turn them into some kind of date string so that i can them go on to say if startdate > enddate then display the alert box? Any help would be greatly appreciated as i have little knowledge of javascript. Cheers Andy
  5. Hi Guys Was hoping someone could help me out with a (simple?) javascript validation i ahve on my form. I have a similar thing working on another form so cant understand why this isnt working. within the <head> tag i have: <script type="text/javascript"> function validateForm(newcat) { if(document.newcat.category.selectedIndex == 0) { alert("Please select a category"); document.forms.newcat.category.focus(); return false; } } </script> My form starts with: <form name="newcat" method="POST" action="<?php echo $PHP_SELF ?>" onSubmit="return validateForm(newcat);"> and there is a dropdown list called "category" within the form. Is it just something simple that im missing? Any help would be greatly appreciated. Cheers Andy
  6. Wow! fast response and perfect solution! Many thanks!
  7. Hi I have been trying to get a value to be selected in a mysql populated dropdown list but can't get it to work and was hoping someone could help I have a database with user info in it and this is an update page where they can update their details. The code i have (which doesn't work) is: <select name="agency"> <? $query1 = mysql_query("SELECT * FROM agents ORDER BY agent ASC",$connect); while($myrow = mysql_fetch_assoc($query1)){ $agent = $myrow['agent']; echo "<option"; if ($agent == $agency) { echo "selected='selected'"; } echo ">$agent</option>"; } ?> </select> The $agency value is the current agency which is stored in the users profile and the value does exist in the list which is being populated (also, i have define $agency further up in my code) so i don't know why the selected value won't display. No value is displayed in the dropdown list on the page - but the values are in the list if i remove the selected='selected' part of the code. Any help yould be greatly appreciated. Merry Christmas Andy
  8. Sure, no problem. So my form had a dropdown field called 'email' but the data in the dropdown was in the format Name (email) and i just wanted the email part for my query. So using Dan's suggestion of explode and trim, i got the following: $start = $_POST['email']; $emailexplode = explode("(",$start); $email = rtrim($emailexplode[1],")"); Hope this helps someone in the future Andy
  9. Hi Ive been trying to solve this problem for a few hours but am having no luck so would appreciate any help Im looking for a function/way of extracting info from a dropdown list when a form is submitted. The form field has a name and email address i.e John (john@smith.com) and i just need the email address part to submit into a mysql database. I tried using the explode() function but this didnt work. Any ideas? Cheers Andy
×
×
  • 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.