Jump to content

ukscotth

Members
  • Posts

    195
  • Joined

  • Last visited

Posts posted by ukscotth

  1. Hi all,

     

    I think this would be done using javascript, Im not really sure.

     

    Im trying to work out a way to split a value between 3 select boxes. For example if the max value was 9 I only want a total value of 9 to be selectable between the 3 select boxes e.g box 1 could have a value of 2, box 2 could have a value of 5 and box 3 could have a value of 2.

     

    Hope that makes sense,

     

    Does anyone know how I could do this please ?

     

    Many thanks,

     

    Scott

  2. Problem solved.

     

    I used this code to check the fields before they were submitted

     

    <script language="javascript" type="text/javascript">
    function checker()
    {
    var myForm = this.document.myForm;
    	if(myForm.from.value == '')	
    	    {
    		     alert("Please Select the pick up area");
    			 myForm.from.focus();
    			 return false;
    	    }
    
    
    	if(myForm.to.value == '')
    		{
    			alert("Please Select the droping area");
    			myForm.to.focus();
    			return false;
    		}
    
    	if(myForm.from.value == myForm.to.value)
    		{
    			alert("Pick up area and droping area should not be same");
    			myForm.to.focus();
    			return false;
    		}
    
    
    }
    </script>

     

    Thanks alot for your help, its most appreciated :)

  3. ok hes just told me that a normal alert box is fine but when i do this it messes up the styling on the page

     

    
    if(isset($_POST['submit'])){
    
    
    if (($_POST['from'] == "") || ($_POST['to'] == "")){
    
    
    
    }else{
    
    header( 'Location:quote_part1.php?from='.$_POST['from'].'&to='.$_POST['to'] ) ;
    
    }
    
    }
    
    any ideas why ?
    
    thanks.
    

  4. Hi,

     

    I'm trying to work out how I can trigger a javascript popup type box in an if statement, to trigger it normally from a button it would be :

     

    <input type="button" value="Display" onclick="javascript: formFunction();" class="submit" />

     

    But I want to use it when people submit a form without filling in some of the fields so something like this :

     

    if  (($_POST['first_name'] == '')) { run javascript popup }
    

     

    Any ideas ?

     

    Many thanks in advance.

     

    Scott

  5. Hi,

     

    Im having troubles setting up the tab order for a small form. When I click in the first input box and press tab it goes to the next input box but when I press tab again it skips the submit button.

     

    Any ideas ?

     

    Heres the code :

     

     <form action="quote_part1.php" method="post">
          <div align="center">
            <p align="center" class="style1"> <br />
              <span class="style3">Pick-up Location : <span class="style5">e.g Gatwick Airport </span></span></p>
            <p>
              <select name="from" id="from" class="editable-select" tabindex="1" >
                <option></option>
                <option>Gatwick Airport Terminal 1</option>
                <option>Gatwick Airport Terminal 2</option>
                <option>Gatwick Airport Terminal 3</option>
                <option>Heathrow Airport Terminal 1</option>
                <option>Luton Airport</option>
              </select>
              <br />
            </p>
            <p align="center" class="style4">Drop-off Location : <span class="style5">e.g Bournemouth </span> </p>
            <p>
              <select name="to" tabindex="2" id="to" class="editable-select" onKeyPress="return submitenter(this,event)" >
                <option></option>
                <option>Gatwick Airport Terminal 1</option>
                <option>Gatwick Airport Terminal 2</option>
                <option>Gatwick Airport Terminal 3</option>
                <option>Heathrow Airport Terminal 1</option>
                <option>Luton Airport</option>
              </select>
            </p>
            <p> </p>
            <p> <img src="images/quote_button.png" tabindex="3" OnMouseOver="this.style.cursor='pointer';"  onclick="document.forms[0].submit()" />   </p>
          </div>
        </form>

     

    Many thanks,

     

    Scott

  6. Hi,

     

    I have been using the following function on my server and it works fine but when I try and use it on a different server it wont seem to work. Any ideas on why it wont work on the new server and any ideas on how I can do some error checking to figure out why ?

     

    Thanks in advance,

     

    Scott

     

    <?php
    function get_driving_information($start, $finish, $raw = false)
    {
         # Convert any lon / lat coordingates
         if(preg_match('@-?[0-9]+\.?[0-9]*\s*,\s*-?[0-9]+\.?[0-9]@', $start))
         {
             $url = 'http://maps.google.co.uk/m/local?q='.urlencode($start);
             if($data = file_get_contents($url))
             {
                 if(preg_match('@<div class="cpfxql"><a href="[^"]*defaultloc=(.*?)&ll=@smi', $data, $found))
                 {
                     $start = trim(urldecode($found[1]));
                 }
                 else
                 {
                     throw new Exception('Start lon / lat coord conversion failed');
                 }
             }
             else
             {
                 throw new Exception('Start lon / lat coord conversion failed');
             }
         }
    
        if(preg_match('@-?[0-9]+\.?[0-9]*\s*,\s*-?[0-9]+\.?[0-9]@', $finish))
         {
             $url = 'http://maps.google.co.uk/m/local?q='.urlencode($finish);
             if($data = file_get_contents($url))
             {
                 if(preg_match('@<div class="cpfxql"><a href="[^"]*defaultloc=(.*?)&ll=@smi', $data, $found))
                 {
                     $finish = trim(urldecode($found[1]));
                 }
                 else
                 {
                     throw new Exception('Finish lon / lat coord conversion failed');
                 }
             }
             else
             {
                 throw new Exception('Finish lon / lat coord conversion failed');
             }
         }
    
        if(strcmp($start, $finish) == 0)
         {
             $time = 0;
             if($raw)
             {
                 $time .= ' seconds';
             }
    
            return array('distance' => 0, 'time' => $time);
         }
    
        $start  = urlencode($start);
         $finish = urlencode($finish);
    
        $distance   = 'unknown';
         $time       = 'unknown';
    
        $url = 'http://maps.google.co.uk/m/directions?saddr='.$start.'&daddr='.$finish.'&hl=en&oi=nojs&dirflg=d';
         if($data = file_get_contents($url))
         {
             if(preg_match('@<span[^>]+>([^<]+) (mi|km)</span>@smi', $data, $found))
             {
                 $distanceNum    = trim($found[1]);
                 $distanceUnit   = trim($found[2]);
    
                if($raw)
                 {
                     $distance = $distanceNum.' '.$distanceUnit;
                 }
                 else
                 {
                     $distance = number_format($distanceNum, 2);
                     if(strcmp($distanceUnit, 'km') == 0)
                     {
                         $distance = $distanceNum / 1.609344;
                     }
                 }
             }
             else
             {
                 throw new Exception('Could not find that route');
             }
    
            if(preg_match('@<b>([^<]*)</b>@smi', $data, $found))
             {
                 $timeRaw = trim($found[1]);
    
                if($raw)
                 {
                     $time = $timeRaw;
                 }
                 else
                 {
                     $time = 0;
    
                    $parts = preg_split('@days?@i', $timeRaw);
                     if(count($parts) > 1)
                     {
                         $time += (86400 * $parts[0]);
                         $timeRaw = $parts[1];
                     }
    
                    $parts = preg_split('@hours?@i', $timeRaw);
                     if(count($parts) > 1)
                     {
                         $time += (3600 * $parts[0]);
                         $timeRaw = $parts[1];
                     }
    
                    $time += (60 * (int)$timeRaw);
                 }
             }
    
            return array('distance' => $distance, 'time' => $time);
         }
         else
         {
             throw new Exception('Could not resolve URL');
         }
    }

  7. Hi,

     

    Im having some troubles with a date picker on a form.  It enters the date into the date field like this : 21 Sep 2011

     

    I want to be able to insert it into a date field in the mysql database but it just enters it as 0000-00-00

     

    Any ideas ?

     

    Many thanks,

     

    Scott.

  8. Hi,

     

    I have a database table which is full of books e.g book_title, book_author, book_date etc.  Im trying to work out a way to list all the authors without duplicating them, if that makes sense.

     

    If I do a simple query and then display the book_author in a loop it will show multiple entries for each author.

     

    I just want it to display each author once.

     

    Hope that makes sense lol sorry Im a newbie.

     

    Anyone know how I can do it ?

     

    Thanks in advance,

     

    Scott.

     

     

  9. Hi all,

     

    Anyone know why this query is giving me the wrong results ?

     

    
    $books2 = mysql_query("SELECT * FROM books WHERE (extra1 LIKE '%$cat%') OR (extra2 LIKE '%$cat%') OR (extra3 LIKE '%$cat%') AND type = 'public'");
    
    

     

    Its giving me results that dont have the 'type' 'public'

     

    Any ideas ?

     

    Many thanks in advance.

     

    Scott

×
×
  • 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.