Split Numbers!

Discussion in 'ASP General' started by Arpan, May 14, 2005.

  1. Arpan

    Arpan Guest

    The number '60' can be written as (50+10) or (25+35) or (15+45) or (7+53) etc... but I want the output as (50+10) only when 60 is typed in a textbox & the Form is submitted. How do I do this?

    Thanks,

    Arpan
    Arpan, May 14, 2005
    #1
    1. Advertising

  2. Arpan

    Evertjan. Guest

    Arpan wrote on 15 mei 2005 in microsoft.public.inetserver.asp.general:

    > The number '60' can be written as (50+10) or (25+35) or (15+45) or
    > (7+53) etc... but I want the output as (50+10) only when 60 is typed
    > in a textbox & the Form is submitted. How do I do this?
    >


    first, never send HTML on usenet.

    ==============

    Would this do?


    <form onsubmit="doit()">
    <input id="myInput">
    ......

    <script>
    function doit(){
    myInput = document.getElementById("myInput")
    if(myInput.value==60)myInput.value="(50+10)"
    }
    </script>


    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
    Evertjan., May 15, 2005
    #2
    1. Advertising

  3. Arpan

    Roland Hall Guest

    "Arpan" wrote in message news:eKzz%...
    The number '60' can be written as (50+10) or (25+35) or (15+45) or (7+53)
    etc... but I want the output as (50+10) only when 60 is typed in a textbox &
    the Form is submitted. How do I do this?

    An ASP alternative would be:

    <%
    dim strInput, postback

    postback = Request.Form("postback")
    if postback = "postback" then
    strInput = Request.Form("myInput")
    if strInput = "60" then
    strInput = "(50 + 10)"
    end if
    end if
    %>

    <form id="myform" name="myform" method="post" action="" />
    <input id="mytext" name="mytext" value="" />
    <input id="postback" name="postback" type="hidden" value="postback" />
    <input type="submit" />
    </form>

    Note: this routine has no security

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, May 15, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    450
  2. Carlos Ribeiro
    Replies:
    11
    Views:
    684
    Alex Martelli
    Sep 17, 2004
  3. trans.  (T. Onoma)

    split on '' (and another for split -1)

    trans. (T. Onoma), Dec 27, 2004, in forum: Ruby
    Replies:
    10
    Views:
    200
    Florian Gross
    Dec 28, 2004
  4. Sam Kong
    Replies:
    5
    Views:
    220
    Rick DeNatale
    Aug 12, 2006
  5. Stanley Xu
    Replies:
    2
    Views:
    582
    Stanley Xu
    Mar 23, 2011
Loading...

Share This Page