I'm a total newbie at Javascript, but a programmer for over 20 years...
so, my plans may be bigger than they are possible.
I'm trying to set with Javascript the value of a form field... easy
enough, right?
e.g. this successfully sets the local form's field:
document.thetes tform.mycity.va lue='paris';
however, I'm not sure how to do the same for a form that's within an
iframe, e.g. (consider that the remote url at example.com has 2 forms in
it; the 2nd frame contains a field called 'city' that I want to set):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"
content="text/html;charset=IS O-8859-1">
<SCRIPT LANGUAGE="JavaS cript" type="text/javascript">
<!--
function setfields()
{
document.theifr ame.document.fo rms[1].city.value='pa ris';
}
//-->
</SCRIPT>
</head>
<body bgcolor="#fffff f">
<form action="test.vs p" method="get" name="thetestfo rm"
enctype="applic ation/x-www-form-urlencoded">
<p><img src="clickme.gi f" alt="" width="90" height="65" border="0"
onclick="setfie lds()"></p>
<input type="text" name="mycity" size="24">
<input type="submit" name="submit">
</form>
<IFRAME name="theiframe "
SRC="http://www.example.com/cityinfo.html" width="95%" height="90%"
scrolling="auto " frameborder="1" >
</IFRAME>
</body>
</html>
this line doesn't seem to kick:
document.theifr ame.document.fo rms[1].city.value='pa ris';
unfortunately, the form on the example.com site does not have a name for
referencing, so I have to reference it as forms[1]... I understand that
this might make the form read only... is there a way to reference it
that's not read only? (or am I off base in my diagnostic?)
the example.com is not a site that I have any control over... gotta work
with what I gots.
thanks much, javascript gurus and galus.
B.
so, my plans may be bigger than they are possible.
I'm trying to set with Javascript the value of a form field... easy
enough, right?
e.g. this successfully sets the local form's field:
document.thetes tform.mycity.va lue='paris';
however, I'm not sure how to do the same for a form that's within an
iframe, e.g. (consider that the remote url at example.com has 2 forms in
it; the 2nd frame contains a field called 'city' that I want to set):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"
content="text/html;charset=IS O-8859-1">
<SCRIPT LANGUAGE="JavaS cript" type="text/javascript">
<!--
function setfields()
{
document.theifr ame.document.fo rms[1].city.value='pa ris';
}
//-->
</SCRIPT>
</head>
<body bgcolor="#fffff f">
<form action="test.vs p" method="get" name="thetestfo rm"
enctype="applic ation/x-www-form-urlencoded">
<p><img src="clickme.gi f" alt="" width="90" height="65" border="0"
onclick="setfie lds()"></p>
<input type="text" name="mycity" size="24">
<input type="submit" name="submit">
</form>
<IFRAME name="theiframe "
SRC="http://www.example.com/cityinfo.html" width="95%" height="90%"
scrolling="auto " frameborder="1" >
</IFRAME>
</body>
</html>
this line doesn't seem to kick:
document.theifr ame.document.fo rms[1].city.value='pa ris';
unfortunately, the form on the example.com site does not have a name for
referencing, so I have to reference it as forms[1]... I understand that
this might make the form read only... is there a way to reference it
that's not read only? (or am I off base in my diagnostic?)
the example.com is not a site that I have any control over... gotta work
with what I gots.
thanks much, javascript gurus and galus.
B.
Comment