View Full Version : FORM question
dallen24
03-30-2003, 08:45 PM
Hi. The U.S. Naval observatory has a web page where you submit your longitutde in a form to get the current sidereal time.
<FORM METHOD="POST" ACTION="http://tycho.usno.navy.mil/cgi-bin/sidereal-post.sh">
<input size=4 name="lond" value=0>
(degrees)
<input size=3 name="lonm" value=0>
(minutes)
<input size=3 name="lons" value=0>
(seconds)
East/West:
<SELECT NAME=ew SIZE=2>
<OPTION value=-1 SELECTED> West
<OPTION value=1 > East
</SELECT>
<BR>
<input type=submit value="Compute">
<input type=reset value="Reset">
</FORM>
But our web site already has the user's longitude. Question. Is there a way to send information to sidereal-post.sh without actually having to create/display a <FORM>? Or wait for the user to press <submit>?
cg9com
03-30-2003, 09:23 PM
you can use a hidden input field. type="hidden"
bryndyment
03-30-2003, 11:51 PM
And you can use myForm.submit() to submit the form you've built up with hidden tags.
<html>
<body onload="document.myForm.submit()"
<form method=post name="myForm" action="http://tycho.usno.navy.mil/cgi-bin/sidereal-post.sh">
<input type=hidden name="lond" value="45">
<input type=hidden name="lonm" value="30">
<input type=hidden name="lons" value="15">
<input type=hidden name="ew" value="1">
</form>
</body>
</html>
Something like that...
cheesebagpipe
03-30-2003, 11:55 PM
Put the form in an iframe and submit it automatically from there. How (and when) you do this is dependent on when the user's longitude is known, and whether it's calculated independently of any user input or via data entry. You'll need to play ball with the service provider, since they're using a cgi script to process your data.
dallen24
03-31-2003, 03:33 PM
Originally posted by cheesebagpipe
Put the form in an iframe and submit it automatically...
How?
cheesebagpipe
03-31-2003, 09:00 PM
Well, the main problem here, imo, isn't the submission - it's deciding what to do with the return document. It's easy enough to submit the data using hidden fields - can't tell you how to populate these without knowing how your "web site already has the user's longitude" - but the server is returning a generated document that's off-limits to scripting, so...what do you do with it?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SIDEREAL CEREAL</title>
<style type="text/css">
div#outer {
position: relative;
width: 218px;
top: -236px;
text-align: center;
}
div#inner {
position: absolute;
left: 0px;
top: 0px;
clip: rect(232px 250px 258px 32px);
}
body {
margin: 0px;
}
</style>
<script type="text/javascript" language="javascript">
onload = function() {
document.forms[0].submit();
}
</script>
</head>
<body>
<hr />
<div id="outer">
<div id="inner">
<iframe name="sidereal" height="400" scrolling="no"></iframe>
</div></div><hr /><hr />
<form method="post" action="http://tycho.usno.navy.mil/cgi-bin/sidereal-post.sh" target="sidereal">
<input type="hidden" name="lond" value="180">
<input type="hidden" name="lonm" value="30">
<input type="hidden" name="lons" value="0">
<input type="hidden" name="ew" value="e">
</form>
</body>
</html>
Just cuts it up and packages it for display. I hardcoded the values; in practice, you'd set them (programmatically) before submitting. Best I could think of...
dallen24
03-31-2003, 10:30 PM
That'll work. Need to set ew = -1 (west) to get the right LST. I didn't know you could execute a submit() within an onload=. Thanks...Dennis
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.