Forms Interface

void htbindform (hrec * r)

htbindform() is a very useful function. And it's so smart too! An HTML form can be viewed as a bunch of input fields of various types, each with a name. An hrec is a datastructure with name/value pairs. htbindform does the obvious thing: mate the name value pairs in r with the current form. htbindform knows how to do most everything with forms including, SELECT, INPUT, TEXTAREA, RADIO, CHECKBOX.

An example might clarify this. Suppose we have a form:

      <form action="/cgi-bin/976hotflesh" method=get>
      <input name=hotflesh value="">
      <input name=babetype value="male" type=radio>
      <input name=babetype value="female" type=radio>
      <select name=orientation>
      <option>fagola
      <option>dyke
      <option>fence sitter
      <option>str8-O      
      </select>
      </form>
      
And we want to load up that form with some values we fished out of our BabeBase:
      /* ... */
      hradd (babe, "hotflesh", "Mike");
      hradd (babe, "babetype", "male");
      hradd (babe, "orientation", "fagola");
      /* assuming we're sitting over a form,
         htbindform will set the values accordingly */
      htbindform (babe);
      /* ... */
      
resulting with HTML that looks like:
      <form action="/cgi-bin/976hotflesh" method=get>
      <input name=hotflesh value="Mike">
      <input name=babetype value="male" type=radio checked>
      <input name=babetype value="female" type=radio>
      <select name=orientation>
      <option selected>fagola
      <option selected>dyke
      <option>fence sitter
      <option>str8-O
      </select>
      </form>
      
Note: htbindform despite being dreadfully brilliant, is, however, less brilliant with multiple selections. Some unkind souls might call it braindead.

htelm * htformn (int n)

Get the n'th form in the current document.

htelm * htpformn (htelm * h, int * n)

Similar to htformn(), but doesn't move point and starts at a the given list element.

htelm * htformnext ()

Get the next form in the document given the current insertion point. This is most useful when used in combination with htgotomark() for positioning yourself over a form. htformnext will always find the next form in the current document regardless of any conditional expansion that might take place.

htelm * htformprev ()

Simliar to htformnext(), go to the previous form.

htelm * htgotofield (char * field)

Position yourself over field field. Not normally useful as most functions implicitly consider the entire form.

htelm * htpgotofield (htelm * h, char * field)

Goto the given field, but start at an abitrary point. Mostly an internal function.

char * htgetfval (char * field, char * var)

Get the value of field field's var. That is to say, given:
          <input name=foo value=bar>
      
htgetfval ("foo", "value") will return "bar".

char * htpgetfval (htelm * h, char * field, char * var)

Same as above, but takes an starting point h

void htputfval (char * field, char * var, char * val)

Put the value val in variable var in field field. That is to say, given:
          <input name=foo value=bar>
      
and htputfval ("foo", "value", "baz") would result in:
          <input name=foo value=baz>
      

void htpputfval (htelm * h, char * field, char * var, char * val)

Same as above, but start at h

void htputftag (htelm * h, char * field, char * var)

place a valueless tag into field field
          <select name=foo>
      
and htputftag ("foo", "multiple") would result in:
          <select name=foo multiple>
      

void htpputtag (htelm * h, char * var)

mostly an internal function, put the tag into the field pointed to by h.

void htputval (char * var, char * val)

htputfval() is really a htpgotofield() followed by a htpputval(). This function provides a direct interface, though probably less useful than it may look.

void htpputval (htelm * h, char * var, char * val)

same as above, but start at h.

void htpdeltag (htelm * h, char * var)

Delete a tag from the given field.


© (copyright) 1997 MTCC
Last modified: Fri Apr 25 20:45:08 PDT 1997