Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

repost data back to html frame

Status
Not open for further replies.

inforeqd

Technical User
Jan 8, 2001
95
US
Ok, I've included alot of bad things in my internal user form. The html link starts a popup with frames. Each frame is configured to utilize a cgi (perl) script to perform a certain action on a remote server via a socket connection. After the action is performed the cgi script queries for the current setting and then reposts it back to the <FORM> on the popup frame document. This all works great at the moment however it doesnt scale.

Heres my example.

<skip the socket code>

read ($socket,$buf,5);
my($value) = $buf =~ /(\d+)/;
#setup the values
$SLOW=1;
$FAST=2;
$MEDIUM=3;

if ($value == $SLOW) {
print "Content-type: text/html \n\n";
print <<END;
<html>
<FORM ACTION="/cgi-bin/chng.pl" METHOD="POST">
<h6> Value: <SELECT NAME="Value" </h6>
<OPTION VALUE="1">Slow
<OPTION VALUE="2">Fast
<OPTION VALUE="3">Medium
</SELECT>
<INPUT TYPE="SUBMIT" VALUE="UPDATE">
</FORM>
</body>
</html>
END
}

elsif ($value == $FAST) {
print "Content-type: text/html \n\n";
print <<END;
<html>
<FORM ACTION="/cgi-bin/chng.pl" METHOD="POST">
<h6> Value: <SELECT NAME="Value" </h6>
<OPTION VALUE="2">Fast
<OPTION VALUE="3">Slow
<OPTION VALUE="1">Medium
</SELECT>
<INPUT TYPE="SUBMIT" VALUE="UPDATE">
</FORM>
</body>
</html>
END
}
More code here deleted for size .. ends with an else statement.

See in the above example if the value is 1 it prints the option list back as 1 2 3. If the value is 2 it prints it back as 2 3 1. This all works but is really inefficient since the next frame has a pulldown with about 1000 options. I really dont want to repeat an if elsif elsif elsif 1000 times and include the html in each, is there a more efficient way to take the input, and push it back to the form that i have embedded in the frame page?
tia
inforeqd
 
Try this:

Code:
print "Content-type: text/html \n\n";
print "<html>\n<FORM ACTION="/cgi-bin/chng.pl" METHOD="POST">\n<h6> Value: </h6> <SELECT NAME="Value">\n";
if ($value == $SLOW) {
  print "<OPTION VALUE="1" selected>Slow</option>\n";
}
else {
  print "<option value="1">Slow</option>\n";
}
if ($value == $MEDIUM) {
  print "<OPTION VALUE="3" selected>Medium</option>\n";
}
else {
  print "<option value="3">Medium</option>\n";
}
if ($value == $FAST) {
  print "<OPTION VALUE="2" selected>Fast</option>\n";
}
else {
  print "<option value="2">Fast</option>\n";
}
print "</SELECT>\n<INPUT TYPE="SUBMIT" VALUE="UPDATE">\n </FORM>\n</body>\n</html>";

- Rieekan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top