SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2003
    Location
    pdx
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    forms and variables

    hello all, my problem is that i would like to set the value of a test field to the value of a variable i got from a cookie. when the page loads and there is no cookie value set i assume that the value should come in null. if there is a cookie value set, then i would liek the text feilds value to be that. am i correct in this thought pattern? this is the dcript i have so far below. i get an error when the page loads,
    onChange="setCookie('name', this.value)
    at this line i get an error that i am missing a ")" around 'name'.
    can anybody solve this perplexing problem? kudo's to those that can, help me please!!

    <form action='WSmainframe.php' method='GET' target='mainframe' name='cart3form'>

    <script language="JavaScript" type="text/JavaScript">

    var name2 = getCookie('name');
    window.document.cart3form.name.value = name2;
    alert(window.document.cart3form.name.value);

    document.write('<td width="60%" align="left"><input type="text" name="name" maxlength="40" size="31" onChange="setCookie('name', this.value)"> </td>');

    </script>
    </form>

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can see a problem with your references

    document.cart3form.name pulls a reference to the name attribute of the form -- not the element with the name "name". So, two fixes

    1) Change the name of the element
    2) Change the reference to this

    document.cart3form.elements['name']

    I highly recommend solution #1.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

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