Web Analytics Made Easy -
StatCounter javascript in an html form - CodingForum

Announcement

Collapse
No announcement yet.

javascript in an html form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • javascript in an html form

    Hi im new to this so was wondering if you could help please.

    I have a form that I would like to display a javascript calculation into the value field.

    The code i Have is

    Code:
    <form name="form1" method="post" action="nextpage.asp">
    <input type="text" name="textfield" value=" document.write(document.applets[0].getLHost());">
    </form>
    Basically I want the
    Code:
    document.write(document.applets[0].getLHost());
    to display as the value in the form field. But when I try this it literally displays the code.

    Can any one help please on how to do this.

  • #2
    Use document.write inside a script tag.

    Code:
    <form name="form1" method="post" action="nextpage.asp">
    <script type="text/javascript"><--
    document.write('<input type="text" name="textField" value="');
    document.write(document.applets[0].getLHost());
    document.write('">"');
    //-->
    </script>
    </form>
    Last edited by VortexCortex; Oct 5, 2006, 03:11 AM. Reason: added code tags

    Comment

    Working...
    X