Question
Is it possible for one form value to reference another currently selected form value upon form submit ?
Take this form as an Example:
<form name="name" action="%SCRIPTURLPATH{save}%/%WEB%/" method="post">
<input type="text" name="firstvalue" size="38" maxlength="36" />
<input type="text" name="secondvalue" size="38" maxlength="36" />
<input type="hidden" name="topic" size="38" maxlength="36" />
<input type="hidden" name="templatetopic" value="SomeTemplate" />
<input type="submit" class="twikiSubmit" value="Create Project Page" />
</form>
I would like to be able to submit the form (upon button click) with the value for the 'name' input equal to the 'firstvalue' input concatenated with the 'secondvalue' input.
I realize that in some cases the template topic could do the concatenation, but this is not possible for topic creation or to populate a template topic form field.
Please help.
Environment
--
JeffLozier - 03 Apr 2008
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
Check out
TWikiRegistration. From there you can use this.
<script language="javascript">
<!--
function capitalise(name)
{
var sIn = name;
var sOut = '';
var chgUpper = true;
for ( var i = 0; i < sIn.length; i++ ) {
var ch = sIn.charAt( i );
var chVal = ch.charCodeAt(0);
var ch2 = '';
if( (chVal==192) || (chVal==193) || (chVal==194) || (chVal==195) ) { ch = 'A'; }
if( chVal==196) { ch = 'A'; ch2 = 'E'; }
if( chVal==197) { ch = 'A'; ch2 = 'A'; }
if( chVal==198) { ch = 'A'; ch2 = 'E'; }
if( chVal==199) { ch = 'C'; }
if( (chVal==200) || (chVal==201) || (chVal==202) || (chVal==203) ) { ch = 'E'; }
if( (chVal==204) || (chVal==205) || (chVal==206) || (chVal==207) ) { ch = 'I'; }
if( chVal==208) { ch = 'd'; }
if( chVal==209) { ch = 'N'; }
if( (chVal==210) || (chVal==211) || (chVal==212) || (chVal==213) ) { ch = 'O'; }
if( chVal==214) { ch = 'O'; ch2 = 'E'; }
if( chVal==216) { ch = 'O'; ch2 = 'E'; }
if( (chVal==217) || (chVal==218) || (chVal==219) ) { ch = 'U'; }
if( chVal==220) { ch = 'U'; ch2 = 'E'; }
if( chVal==221) { ch = 'Y'; }
if( chVal==222) { ch = 'P'; }
if( chVal==223) { ch = 's'; ch2 = 's'; }
if( (chVal==224) || (chVal==225) || (chVal==226) || (chVal==227) ) { ch = 'a'; }
if( chVal==228) { ch = 'a'; ch2 = 'e'; }
if( chVal==229) { ch = 'a'; ch2 = 'a'; }
if( chVal==230) { ch = 'a'; ch2 = 'e'; }
if( chVal==231) { ch = 'c'; }
if( (chVal==232) || (chVal==233) || (chVal==234) || (chVal==235) ) { ch = 'e'; }
if( (chVal==236) || (chVal==237) || (chVal==238) || (chVal==239) ) { ch = 'i'; }
if( chVal==240) { ch = 'd'; }
if( chVal==241) { ch = 'n'; }
if( (chVal==242) || (chVal==243) || (chVal==244) || (chVal==245) ) { ch = 'o'; }
if( chVal==246) { ch = 'o'; ch2 = 'e'; }
if( chVal==248) { ch = 'o'; ch2 = 'e'; }
if( (chVal==249) || (chVal==250) || (chVal==251) ) { ch = 'u'; }
if( chVal==252) { ch = 'u'; ch2 = 'e'; }
if( chVal==253) { ch = 'y'; }
if( chVal==254) { ch = 'p'; }
if( chVal==255) { ch = 'y'; }
if( ch!=' ') {
if( chgUpper ) {
ch = ch.toUpperCase(); chgUpper = false;
}
sOut+=ch;
if( ch2!='') {
sOut+=ch2;
}
} else {
chgUpper = true;
}
}
return sOut;
}
//-->
</script>
<form name="name" action="%SCRIPTURLPATH%/save%SCRIPTSUFFIX%/%WEB%/" method="post">
<input type="text" name="firstvalue" size="38" maxlength="36" />
<input type="text" name="secondvalue"
onblur="this.form.topic.value=capitalise(this.form.firstvalue.value)+capitalise(this.value)"
size="38" maxlength="36" />
<input type="hidden" name="topic" size="38" maxlength="36" />
<input type="hidden" name="templatetopic" value="SomeTemplate" />
<input type="submit" class="twikiSubmit" value="Create Project Page" />
</form>
--
EnriqueCadalso - 03 Apr 2008
Good answer Enrique. Closing question...
--
PeterThoeny - 11 May 2008