[Gllug] Re: javascript question (Adrian McMenamin)

Adrian McMenamin adrian at mcmen.demon.co.uk
Fri Apr 19 23:27:13 UTC 2002


On Friday 19 Apr 2002 10:21 am, you wrote:
> Hi Adrian
>
> >Why does Mozilla trap expired credit cards - but Konqueror (and the Evil
> >Empire's browser) do not?

.......


> Is the entry field a text box or a select?
> If it's a select you need to use selectedIndex e.g.
>
> var cc_m = document.ticket_order.card_month;
> if (right_now.getMonth() >=
> parseInt(cc_m.options[cc_m.selectedIndex].value)) ...
>
> Jon Ramsey
>

Well it was a select and I changed the code...

	    var cc_y = document.ticket_order.card_year;
		    if (parseInt(cc_y.options[cc_y.selectedIndex].value, 10) == 2) /* ie 
2002 */
		    {
		    var right_now = new Date;
		    var cc_m = document.ticket_order.card_month;
		    if (right_now.getMonth() >= 
parseInt(cc_m.options[cc_m.selectedIndex].value, 10))
		    {
		    alert("Sorry, your credit card appears to have expired. Please check 
the expiry date.");
		    return false;
		    }
		    }
		    }

And now it works in neither Mozilla nor Konq!!!

Here is the html....

                      <td width="20%"> 
                          <select name="card_month" size="1">
                            <option>01</option>
                            <option>02</option>
                            <option>03</option>
                            <option>04</option>
                            <option>05</option>
                            <option>06</option>
                            <option>07</option>
                            <option>08</option>
                            <option>09</option>
                            <option>10</option>
                            <option>11</option>
                            <option selected>12</option>
                          </select>
                        </td>
                        <td width="15%"> 
                          <p align="left"><font face="Arial, Helvetica, 
sans-serif" size="2" color="#000000">Year</font></p>
                        </td>
                        <td width="46%"> 
                          <select name="card_year" size="1">
                            <option selected>02</option>
                            <option>03</option>
                            <option>04</option>
                            <option>05</option>
                            <option>06</option>
                            <option>07</option>
                            <option>08</option>
                            <option>09</option>
                            <option>10</option>
                            <option>11</option>
                            <option>12</option>
                          </select>
                        </td>

So what on Earth is going on?

Adrian

PS Mozilla's js console says....

Error cc_m has no properties, 

(while cc_y is reported to be null!)


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list