Results 1 to 9 of 9

Thread: Input Button

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Input Button

    Ok I have this code here that searches another window for a particular word ok.


    Look

    Code:
    <body>
    
    <input type="button" value="Find" onClick="findit()">
    
    </form>
    
    <script language="JavaScript">
    
    var pos = 0;
    function findit() {
    
    	if (document.myform.mytext.value == '') {
            alert('Nothing to search for');
            return;
        }
        if (document.all) {
            var found = false;
            var text = opener.document.body.createTextRange();
            for (var i=0; i<=pos && (found=text.findText(document.myform.mytext.value)) != false; i++) {
                text.moveStart("character", 1);
                text.moveEnd("textedit");
            }
            if (found) {
                text.moveStart("character", -1);
                text.findText(document.myform.mytext.value);
                text.select();
                text.scrollIntoView();
                pos++;
            }
            else {
                if (pos == '0')
                    alert('"' + document.myform.mytext.value +'" was not found on this page.');
                else
                    alert('No further occurences of "' + document.myform.mytext.value +'" were found.');
                pos=0;
            }
        }
        else if (document.layers) {
            opener.find(document.myform.mytext.value,false);
        }
    }
    
    //--></script>
    
    
    </body>
    Ok you see the

    Code:
    <input type="button" value="Find" onClick="findit()">
    Well the value = Find but when I click it the first time i would like it to change to Find Next!!!!

    Also if they change the word they are looking for I want to change the button value to find again!

    Is there any way of disabling the maximize button on my form??


    Please Help


    Regards


    MattJH

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    suggestion for changing your button value:

    i don't know how to do it directly but,


    just use two layer:

    in one have your button with the value find

    and the other layer with the value find next,

    so just show & hide your layer!!!

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    I am sorry

    I am a bit of a newbie to this, how do I make layers????

    Cheers.

  4. #4
    New Member
    Join Date
    Jul 2001
    Location
    Oxford, England
    Posts
    13

    Talking

    You can make layers by adding CSS properties to the page (any item can have it's position changed with CSS )

    Example:

    <input type="button" value="Button">

    <input type="button" value="Button" style="position: absolute; left: 26; top: 26">

    If you copy that straight into an editor you should see the second button overlapping the first one.

    All you would have to do is alter the visibility of one of the buttons to make it look as though the text is changing on a single button. Even though each button would retain it's functionality as they both have separate code .

  5. #5
    scoutt
    Guest
    only problem with that is it will not work in NS4.x, not sure about NS6, but 4.x does not support style tages or in fact most of CSS scripts.

    just my .02

  6. #6
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    You can set up a flag to indicate that the button was clicked already then reset the VALUE of the button in code:

    <html>
    <head>
    <title></title>

    <script LANGUAGE = "JavaScript">

    var buttonClicked = false; //Must be Public to all functions

    function changeButton(){

    buttonClicked = true;

    if(buttonClicked){
    frmMain.cmdFind.value = 'Find Next';
    }//end if

    }//end function

    </script>
    </head>
    <body>
    <form NAME = "frmMain">
    <input TYPE = "button" NAME = "cmdFind" VALUE = "Find" ONCLICK = "changeButton();"
    </form>
    </body>
    </html>


    Chris
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  7. #7
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    Oops...

    I missed the part about resetting it back to find. You can reset the flag in the ONCHANGE event of the textbox or change the VALUE directly there.

    buttonClicked = false;
    frmMain.cmdFind.value = 'Find';


    Chris
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Forms

    buttonClicked = false;
    frmMain.cmdFind.value = 'Find';

    With this "frmMain" you mean a userform created by the visual basic editor???

    If so how can I get the frmMain to appear when I click on a button within my html page??

    Cheers

  9. #9
    Fanatic Member Psyrus's Avatar
    Join Date
    Jul 2000
    Location
    NJ
    Posts
    602
    frmMain is just the name that I gave to the form. You can give it whatever name you like. I just tend to use the VB style names frmForm, cmdButton, txtTextInput etc...


    Chris
    Chris

    VB 6.0 Calendar App Video Gamers Group
    Don't forget to rate people if they helped you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width