|
-
Jun 27th, 2001, 08:27 AM
#1
Thread Starter
Hyperactive Member
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
-
Jun 27th, 2001, 10:47 AM
#2
Frenzied Member
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!!!
-
Jun 28th, 2001, 02:59 AM
#3
Thread Starter
Hyperactive Member
I am sorry
I am a bit of a newbie to this, how do I make layers????
Cheers.
-
Jul 3rd, 2001, 05:20 PM
#4
New Member
-
Jul 3rd, 2001, 08:22 PM
#5
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
-
Jul 4th, 2001, 10:27 AM
#6
Fanatic Member
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
-
Jul 4th, 2001, 10:31 AM
#7
Fanatic Member
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
-
Jul 10th, 2001, 06:43 AM
#8
Thread Starter
Hyperactive Member
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
-
Jul 10th, 2001, 05:31 PM
#9
Fanatic Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|