Question

I am new to perl and i have a button that when a user pressed that button, the value in the configuration file will be set to default. Here is my configuration file named config.conf :

[status]
status.state=1
status.state2=0
status.state3=1

I want the configuration above to be set as default value means that the value that is 1 or 0 will be as default value. When a user change the value, for example :

[status]
status.state=1
status.state2=1
status.state3=0

And the user pressed the default button, the value in the configuration file will be the same as shown in the first one. How can i do this? What function do i need to use?

Here is my code for the interface :

#!/usr/bin/perl
#index.cgi

require 'foobar-lib.pl';

ui_print_header(undef, $module_info{'desc'}, "", undef, 1, 1);
ui_print_footer("/", $text{'index'});

print "Content-type:text/html\n\n";
print qq~<html>
<link rel="stylesheet" type="text/css" href="style.css">
<body>

<div id="content">
<div id="bar">
<span><p>Voice</p></span>
</div>
<div id="main-container">
<table width="100%" height="100%">
<tr>
<td width="30%" align="left">
<div id="title"><span>BYPASS :</span></div>
</td>
<td width="35%">
<div id="form">
<form method="POST" action="index2.cgi">
<select name="vdgpb" size="1">
  <option value="bypass_a">VOC_BYPASS_A</option>
  <option value="bypass_b">VOC_BYPASS_B</option>
  <option value="bypass_c">VOC_BYPASS_C</option>
  <option value="bypass_d">VOC_BYPASS_D</option>
</select>
</td>
<td align="left">
<input type="radio" name="pb" value="1">High (1)
</br>
<input type="radio" name="pb" value="0">Low (0)
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="description"><b>Description :</b></div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="button">
<input type="submit" value="Submit"><input type="reset" value="Clear">
</form>
</div>
</td>
</tr>
<tr>
<td wiidth="30%" align="left">
<div id="title"><span>SELECTION A :</span></div>
</td>
<div id="form">
<form method="POST" action="index3.cgi">
<td width="35%">
<select name="vdgph" size="1">
  <option value="sel_a">SEL A</option>
  <option value="sel_b">SEL B</option>
  <option value="sel_c">SEL C</option>
  <option value="sel_d">SEL D</option>
</select>
</td>
<td align="left">
<input type="radio" name="ph" value="1">High (1)
</br>
<input type="radio" name="ph" value="0">Low (0)
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="description"><b>Description :</b></div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="button">
<input type="submit" value="Submit"><input type="reset" value="Clear">
</form>
</div>
</td>
</tr>
<tr>
<td width="30%" align="left">
<div id="title"><span>IMPEDENCE</span></p>
<p><span>SELECTION :</span></p>
</div>
</td>
<div id="form">
<form method="POST" action="index4.cgi">
<td width="35%">
<select name="vdgpk" size="1">
  <option value="z1_a">Z1_A</option>
  <option value="z1_b">Z1_B</option>
  <option value="z1_c">Z1_C</option>
  <option value="z1_d">Z1_D</option>
  <option value="z2_a">Z2_A</option>
  <option value="z2_b">Z2_B</option>
  <option value="z2_c">Z2_C</option>
  <option value="z2_d">Z2_D</option>
</select>
</td>
<td align="left">
<input type="radio" name="pk" value="1">High (1)
</br>
<input type="radio" name="pk" value="0">Low (0)
</div>
</td>
<tr>
<td colspan="3">
<div id="description"><b>Description :</b></div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="button">
<input type="submit" value="Submit"><input type="reset" value="Clear">
</form>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div id="button">
<form action="index5.cgi"
<input type="submit" value="Default Settings">
</form>
</div>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
~; 
Was it helpful?

Solution

Your CGI output is hendered as HTML in the browser so it is easiest to use an HTML component to do it for you. A reset button will do the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top