|
Out ( 'Email:' ); Out ( '</td><td align="left" valign="top">' ); // a simple text box. we'll reference it with the name "name" // and show 22 characters on the form. use the maxlength // attribute to set the maximum characters they can enter. // use value="some text" to pre-fill the input with data. // // IMPORTANT! using names that are commonly used by // other web sites has a big advantage to the user - IE // will drop down a list of previous answers, which they // can usually pick from rather than type in. Think about this. Out ( '<input type="text" name="email" size="31" value="' + sEmail + '"></input>' ); Out ( '</td></tr>' );
Out ( '<tr><td align="right" valign="top">' ); Out ( ' ' ); Out ( '</td><td align="left" valign="top">' ); // type='submit" provides a submit button to perform the // form action. the button says "Submit" unless you override // with the value attribute. Out ( '<input type="submit" name="action" value="Subscribe"></input> <input type="submit" name="action" value="Unsubscribe"></input>' ); Out ( '</td></tr>' );
Out ( '</table>' ); Out ( '</form></center>' ); } else { var sAction = "" + Request.Form ( "action" );
if ( sAction == "Subscribe" ) AddEmail ( sEmail ) ; else RemoveEmail ( sEmail );
Out ( '<p>' ); }
Out ( 'Do you want to see how this form adds and removes addresses to my database? All the source code is just a click away!' ); Out ( '<p><center><a href="ShowSource.asp? page=Subscribe"><img src="images/source.gif" border=0></a></center>' ); Out ( '<p>In <a href="MailToList.asp">Part 2</a> see how I wrote a form to mail all my subscribers...' );
Out ( '</td>' ); Out ( '<td width="20%"> </td>' ); }
// ============================================ // validate email address // ============================================ function IsValidEmail ( sEmail ) { // regular expression courtesy of ed.courtenay@nationwideisp.net // I won't even pretend that I've read through this yet!
|