Hi Tom,

> Running the attached tying in the searchbar :
>
> ukrail /from newcastle /to london waterloo /outtime 15:30

Had a chance to look at your code today...

You did not have several of the form elements required to make your
code work (notably the outHourField and outMinuteField, but the "ret"
fields, as well).

And it looks like the biggest potential problem was with your
comparison operator - you were using "=" instead of "==". In
JavaScript you compare values using ==, not =. I've attached a 'fixed'
and working copy. I didn't add any new functionality, so it doesn't
include the ability to schedule return times yet. I leave that as an
excersize for the reader. ;)

Lastly, it doesn't like the default of 'today' if the current local pc
time is after the UK time. Since it's tomorrow there and only today
here, this would be a bit of a pain to correct easily. Fortunately
this is probably not going to be much of an issue for those of us that
are 'remote' - since finding out what time the rail departs today is
likely not an issue. ;)

Regards,

Shawn K. Hall
http://ReliableAnswers.com/

'// ========================================================
     You can name your own salary here  -  I call mine Fred
<search function="ukrail">
  <name>UK National rail enquiries</name>
  <category>People and Places</category>
  <contributor>Tom Corcoran</contributor>
  <link>http://www.nationalrail.co.uk/planmyjourney/time_table/journey_requirements.asp</link>
  <email></email>
  <description>
  </description>
  <form name="ukrailf"
        method="post"
        action="http://www.nationalrail.co.uk/planmyjourney/time_table/Home_Validate_Timetable.asp";>

    <input type="hidden" name="0" value="" />
    <input type="hidden" name="1" value="" />
    <input type="hidden" name="3" value="" />
    <input type="hidden" name="11" value="" />
    <input type="hidden" name="datesel" value="custom" />
    <input type="hidden" name="datesel" value="tomorrow" />
    <input type="hidden" name="9" value="D" />
    <input type="hidden" name="14" value="" />
    <input type="hidden" name="outHourField" value="" />
    <input type="hidden" name="outMinuteField" value="" />
    <input type="hidden" name="retHourField" value="" />
    <input type="hidden" name="retMinuteField" value="" />

    <COMMENT>
      The input element, "9", was a SELECT element Depart/Arrive
      The input element, "outHourField", was a SELECT element 00..23
      The input element, "outMinuteField", was a SELECT element 00/15/30/34
      The input element, "27", was a SELECT element Unlimited changes/Direct trains/Three changes/Two changes/One change
      The input element, "12", was a SELECT element Depart/Arrive
      The input element, "retHourField", was a SELECT element 00..23
      The input element, "retMinuteField", was a SELECT element 00/15/30/34
    </COMMENT>

  </form>
  <script><![CDATA[
    function ukrail(q)
    {
      if( nullArgs("ukrail",q) )
        return false;
      else
      {
        var args = parseArgsEx(q, "from, to, via, date, outtime, outdepart, outarrival, latest, today, tomorrow, changes");
        
        if( args.switches.length > 0 )
        {
          for( var j=0; j<args.switches.length; j++ )
          {
            switch( args.switches[j].name )
            {
              case "from":
                document.ukrailf["0"].value = args.switches[j].value;
                break;
              case "to":
                document.ukrailf["1"].value = args.switches[j].value;
                break;
              case "via":
                document.ukrailf["3"].value = args.switches[j].value;
                break;
              default:
                break;
              case "date":
                document.ukrailf["11"].value = args.switches[j].value;
                break;
              case "outtime":
                outtime = args.switches[j].value;
                outhour = outtime.substring(0,2);
                outmin = outtime.substring(3,5);
                document.ukrailf["outHourField"].value = outhour;
                document.ukrailf["outMinuteField"].value = outmin;
                break;
              case "outarrival":
                document.ukrailf["9"].value = "D";
                break;
              case "outdepart":
                document.ukrailf["9"].value = "A";
                break;
            }
          }
          if (document.ukrailf["11"].value == '')
          {
            var dat = new Date();
            var today = dat.getDate().toString();
            document.ukrailf["11"].value = today;
          }
        }
      }  
      submitForm(ukrailf);
    }
  ]]></script>
  <copyright>
    The following applies if this file is included and distributed with Dave's Quick Search Deskbar:
    Copyright (c) 2002 David Bau; Distributed under the terms of the GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
  </copyright>
  <created_by>
    This search file was initially created on 01/12/04 at 11:39:21
    by Dave's Quick Search Deskbar Search Wizard version 1.2,
    Copyright (c) 2002 Glenn Carr; Distributed under the terms of the GNU General Public License, Version 2
  </created_by>
</search>

Reply via email to