-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest2
executable file
·59 lines (46 loc) · 1.76 KB
/
test2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
use CGI;
$query = new CGI;
$JSCRIPT=<<END;
function inputBoxFocusListener(e, eltId)
{
if(document.getElementById(eltId).value == 'Type Something In Here')
document.getElementById(eltId).value = '';
}
function inputBoxBlurListener(e, eltId)
{
if(document.getElementById(eltId).value.length == 0)
document.getElementById(eltId).value = 'Type Something In Here';
};
function setupTextBox(inputId)
{
if(document.getElementById(inputId).value.length == 0 )
document.getElementById(inputId).value = 'Type Something In Here';
YAHOO.util.Event.addListener(inputId, "focus", inputBoxFocusListener, inputId);
YAHOO.util.Event.addListener(inputId, "blur", inputBoxBlurListener, inputId);
};
function addAnotherField()
{
var count = document.getElementsByTagName('input').length-1;
var div = null;
var div = document.getElementById('divId0').cloneNode(true);
var newInputBox = YAHOO.util.Dom.getFirstChild(div);
div.id = div.id.replace("0", count);
newInputBox.id = newInputBox.id.replace("0", count);
newInputBox.value = '';
YAHOO.util.Dom.insertAfter(div, document.getElementById('divId0'));
setupTextBox(newInputBox.id);
};
END
print $query->header;
print $query->start_html(-title => 'Multiple Forms',
-script => [{-src => 'http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js'}, {-code => $JSCRIPT}]
);
print $query->button(-name => 'nothing',
-value => 'Add another field',
-onclick => 'addAnotherField()',
);
print $query->start_div( {-id => 'divId0',});
print $query->popup_menu(-id => 'textBoxId0', -values => [qw/bod dog soon moon/], -default => 'moon',);
print $query->end_div;
print $query->end_html;