joe@sutekh137.net (JoeK) wrote in message news:<478a5314.0408150749.468b2d9@posting.google.c om>...[color=blue]
> Hey all,
>
> I am automating a web page from Visual Foxpro.[/color]
I do not know Visual Foxpro. Hope that my answer will still be on
track.
[color=blue]
>
> oIE.Document.Forms("searchform").Item(<name>).Valu e = <myvalue>
>
> But I cannot control a dropdown with an onchange event. I can set the
> dropdown's value and selectedIndex,[/color]
I assume you are setting these things from javascript.
[color=blue]
> but then calling the onChange() or
> Click() does not do anything.[/color]
I asume you mean the event handlers are not called when you chanage
the values. This is true. They are not called. You need to call
the functions directly after you change the data in javascript.
[color=blue]
> It only seems to fire the onchange if I
> use it interactively.[/color]
True. The event handlers response only to screen input.
[color=blue]
>
> I know what the onChange calls on the form, and I can call the
> function directly, but I don't know how.[/color]
It is a standard call. The user of the this keyword makes the
function call looks special, but it is a standard function call. You
have to supply whatever the this would have supplied because you will
not be in the this scope chain. ( I do not think, but you can try.)
[color=blue]
> How does one call a straight
> JavaScript function that is in the script portion of the web page and
> have it fire as if it was called from the page itself?
>[/color]
Here is my file where I have one style of call with the this and
another without. It is probably best to first run this file. It will
explain more about what is going on.
Robert
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<Title>My color test</Title>
<script type="text/javascript">
function processColors(form)
{
var box;
box = document.createElement("p");
document.body.appendChild(box);
box.innerHTML = "<p>Display all <b>three</b> inputs.</p>";
for (var i=1; i<=3; i++)
{
// Here I call the onchange function.
displayOneColor(form,"color"+i);
}
return true;
} //end function
function displayOneColor (form,theColor)
{
var colorList = ["green","blue","red","black"];
var boxColor;
var box;
boxColor=form.elements[theColor].value;
box = document.createElement("p");
document.body.appendChild(box);
box.innerHTML =
"<p><span style='color:" + colorList[boxColor] + "';>" +
"You picked color "+ colorList[boxColor] +
" for input " + theColor + "." +
"</span></p>";
}
function validateOnSubmit(form)
{
alert("in validateOnSubmit.");
}
</script>
</HEAD>
<BODY >
<p>This files show how you can call an onchange event
handler directly in the onchange event or indirectly from
another function. The
function displayOneColor is called from each of the onchange
event handler in the select tags. To see the direct call, look in the
for loop
of processColors.</p>
<p>Changing on of the colors in the three select box
will display a message at the bottom of the screen.
Clicking on the GO button will show all three color
selections. Clicking on Submit Query will erase all
the color messages since the file is being reloaded. </p>
<form name="form1"[color=blue]
>[/color]
Pick color 1:
<SELECT name="color1" name=color1 style="WIDTH: 180px"
onchange="displayOneColor(this.form,this.name);">
<OPTION value = "0" >Green
<OPTION value = "1" >Blue
<option value = "2" >Red
<option value = "3" >Black
</OPTION></SELECT>
<br><br>
Pick color 2:
<SELECT name="color2" style="WIDTH: 180px"
onchange="displayOneColor(this.form,this.name);">
<OPTION value = "0" >Green
<OPTION value = "1" >Blue
<option value = "2" >Red
<option value = "3" >Black
</OPTION></SELECT>
<br><br>
Pick color 3:
<SELECT name="color3" style="width: 180px"
onchange="displayOneColor(this.form,this.name);">
<OPTION value = "0" >Green
<OPTION value = "1" >Blue
<option value = "2" >Red
<option value = "3" >Black
</OPTION></SELECT>
<br>
<input TYPE=BUTTON NAME="cmdCalc" VALUE="GO"
onClick="processColors(this.form)">
<br><br>
<input type="submit">
</BODY>
</HTML>