anyone good with java script-toggle text on input button

Discussion in 'ASP .Net' started by Paul, Mar 28, 2008.

  1. Paul

    Paul Guest

    Hi I need to toggle the text on an html input button in a .net web application.
    the name of the button is btn_hide and I do have an onclick function for it.

    <script language="javascript" type="text/javascript">
    // <!CDATA[

    function btn_hide_onclick()
    {

    }

    // ]]>
    </script>
    --
    thanks,
    Paul G
    Software engineer.
     
    Paul, Mar 28, 2008
    #1
    1. Advertising

  2. "Paul" <> wrote in message
    news:...

    > <script language="javascript" type="text/javascript">


    Firstly, get rid of the language tag, as that's deprecated syntax...

    > Hi I need to toggle the text on an html input button in a .net web
    > application.


    Toggle? From what to what? I.e. what precisely do you want to happen when a
    user clicks the button...?


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Mar 28, 2008
    #2
    1. Advertising

  3. Paul

    Paul Guest

    hi thanks for the response. I got it working by toggling the state of a
    variable, just wanted the text to change back and forth each time the user
    clicks on it. hide,expand,hide,expand. Should the
    <script language="javascript" type="text/javascript">
    be removed?
    I double clicked on the input button in the aspx page and the designer in
    vs2005 auto created this tag.

    --
    Paul G
    Software engineer.


    "Mark Rae [MVP]" wrote:

    > "Paul" <> wrote in message
    > news:...
    >
    > > <script language="javascript" type="text/javascript">

    >
    > Firstly, get rid of the language tag, as that's deprecated syntax...
    >
    > > Hi I need to toggle the text on an html input button in a .net web
    > > application.

    >
    > Toggle? From what to what? I.e. what precisely do you want to happen when a
    > user clicks the button...?
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
     
    Paul, Mar 28, 2008
    #3
  4. Mark Rae [MVP], Mar 28, 2008
    #4
  5. Quick 'n' Dirty:

    <script type="text/javascript">
    function toggle()
    {
    value = document.getElementById("myButt").value;
    if(value=="First")
    document.getElementById("myButt").value="Second";
    else
    document.getElementById("myButt").value="First";
    }
    </script>

    <input type = "button" id="myButt" value="First" onclick="toggle();"/>

    -- Peter
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short Urls & more: http://ittyurl.net


    "Paul" wrote:

    > Hi I need to toggle the text on an html input button in a .net web application.
    > the name of the button is btn_hide and I do have an onclick function for it.
    >
    > <script language="javascript" type="text/javascript">
    > // <!CDATA[
    >
    > function btn_hide_onclick()
    > {
    >
    > }
    >
    > // ]]>
    > </script>
    > --
    > thanks,
    > Paul G
    > Software engineer.
     
    Peter Bromberg [C# MVP], Mar 29, 2008
    #5
  6. Paul

    Paul Guest

    ok thanks I removed the language tag. I am changing the value of the button
    from hide to expand as I am collapsing and expanding a panel.

    --
    Paul G
    Software engineer.


    "Mark Rae [MVP]" wrote:

    > "Paul" <> wrote in message
    > news:...
    >
    > > just wanted the text to change back and forth each time the user clicks on
    > > it

    >
    > OK, but change from what to what...?
    >
    > > Should the <script language="javascript" type="text/javascript"> be
    > > removed?

    >
    > No. As I said, the language tag should be removed as it is deprecated:
    > http://www.google.co.uk/search?sour...GBGB252GB252&q=language javascript deprecated
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >
     
    Paul, Mar 31, 2008
    #6
  7. Paul

    Paul Guest

    ok thanks it works!
    --
    Paul G
    Software engineer.


    "Peter Bromberg [C# MVP]" wrote:

    > Quick 'n' Dirty:
    >
    > <script type="text/javascript">
    > function toggle()
    > {
    > value = document.getElementById("myButt").value;
    > if(value=="First")
    > document.getElementById("myButt").value="Second";
    > else
    > document.getElementById("myButt").value="First";
    > }
    > </script>
    >
    > <input type = "button" id="myButt" value="First" onclick="toggle();"/>
    >
    > -- Peter
    > Site: http://www.eggheadcafe.com
    > UnBlog: http://petesbloggerama.blogspot.com
    > Short Urls & more: http://ittyurl.net
    >
    >
    > "Paul" wrote:
    >
    > > Hi I need to toggle the text on an html input button in a .net web application.
    > > the name of the button is btn_hide and I do have an onclick function for it.
    > >
    > > <script language="javascript" type="text/javascript">
    > > // <!CDATA[
    > >
    > > function btn_hide_onclick()
    > > {
    > >
    > > }
    > >
    > > // ]]>
    > > </script>
    > > --
    > > thanks,
    > > Paul G
    > > Software engineer.
     
    Paul, Mar 31, 2008
    #7
    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. =?Utf-8?B?S2VpdGggSGFycmlz?=

    How to toggle visibilty of button inside repeater control

    =?Utf-8?B?S2VpdGggSGFycmlz?=, Nov 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,984
    Karl Seguin
    Nov 5, 2004
  2. sapo
    Replies:
    0
    Views:
    582
  3. Todd
    Replies:
    3
    Views:
    758
    Michael Jung
    Aug 30, 2007
  4. Kingo

    Q/A Toggle Script

    Kingo, May 10, 2006, in forum: Javascript
    Replies:
    2
    Views:
    99
    Kingo
    May 10, 2006
  5. newfie912
    Replies:
    2
    Views:
    168
Loading...

Share This Page