how to escape dash in form field name

Results 1 to 3 of 3

Thread: how to escape dash in form field name

  1. #1
    Join Date
    Dec 1969
    Posts
    2

    Default how to escape dash in form field name

    I need to refer to a HTML form field name in JScript that contains a dash in it (&#060;input name="where-taxon"&#062;), but whereas Netscape JavaScript doesn&#039;t have a problem, IE&#039;s JScript interprets the field name as a negation of two variables (where - taxon). <BR><BR>What I&#039;m doing is pasting a value from an index in a child window into a field parent document:<BR><BR>&nbsp;&nbsp;function indexLookup(taxon) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;opener.document.form s[0].where-taxon.value = taxon;<BR>&nbsp;&nbsp;&nbsp;&nbsp;self.close();<BR >&nbsp;&nbsp;}<BR><BR>I can&#039;t rename the field, so I am looking for a way to get IE to escape the dash or otherwise recognize the form element. <BR>I&#039;ve tried escaping it with a backslash (where-taxon), and messing around with various quotes and braces. <BR>I&#039;d rather not resort to the elements[] array to specify the field since the form dyncamicaly changes element positions (based on whether a cookie is set). <BR><BR>Any ideas?<BR>Mucho Thanks,<BR>Tony<BR>www.calflora.org<BR>Biodiversit y information on California wild plants for conservation, research, and education.

  2. #2
    Join Date
    Dec 1969
    Posts
    19,082

    Default RE: how to escape dash in form field name

    use the elements array associatively<BR><BR>document.forms[&#039;formname&#039;].elements[&#039;field-with-dashes&#039;].value<BR><BR><BR><BR><BR>j<BR>http://www.readthe****ingmanual.co.uk/

  3. #3
    Join Date
    Dec 1969
    Posts
    2

    Default RE: how to escape dash in form field name

    D&#039;oh! but of course... <BR><BR>This is going to make our users very happy to not have to navigate 15,000 plus plant names in a slow table.<BR><BR>The non-profit botanical community of California (and I!) thanks you!<BR><BR>-Tony

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •