Why use 1 function with unecessary logic when 3 simple functions would do?

i.e. Javascript:inc(), Javascript:dec(), Javascript:clear()

function inc() { document.getElementById("entry1").value++; }
function dec() { document.getElementById("entry1").value--; }
function clear() { document.getElementById("entry1").value=0; }

Much nicer!

- C

On 9/24/05, thomas favennec <[EMAIL PROTECTED]> wrote:
> ex: Counter for XUL challenge 2004
>
> <xmind title="Xmind counter (V2) - XUL challenge 2004">
>  <frame title="Counter">
>   <vbox>
>    <hbox>
>     <label>Count:</label>
>     <entry name="entry1" width="200">0</entry>
>    </hbox>
>    <hbox>
>     <button onclick="Javascript:act(1)">Dec (-)</button>
>     <button onclick="Javascript:act(2)">Clear</button>
>     <button onclick="Javascript:act(3)">Inc (+)</button>
>    </hbox>
>   </vbox>
>  </frame>
>  <script>
>   <![CDATA[
>    function act(n) {
>     a=document.getElementById("entry1");
>     if(n==1) a.value--;
>     if(n==2) a.value=0;
>     if(n==3) a.value++; }
>   ]]>
>  </script>
> </xmind>


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
XUL News Wire      - http://xulnews.com
XUL Job Postings   - http://xuljobs.com
Open XUL Alliance - http://xulalliance.org
_______________________________________________
xul-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xul-talk

Reply via email to