Results 1 to 3 of 3

Thread: Why doesn't this work??? - [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Why doesn't this work??? - [RESOLVED]

    I am trying to change a hidden fields value.
    The ChangeReviewValue function...takes a strValue (true or false, depending of if the checkbox is checked, and the value of the checkbox)...I want to then set the value of the hidden field with the same name as the value of the checkbox....Anyway I try it I get errors!!! Any Ideas on how I can do this???

    Example:
    If they click the first checkbox...the strValue passed will be true, and the fieldName passed will be the checkboxes value (Reviewed_{7hd6-38dh-d83k-93j3})...What should happen next is, the hidden field with the name (Reviewed_{7hd6-38dh-d83k-93j3}, this matches the value passed from the checkbox) should have its value set to 2.

    Code:
    <script language="JavaScript">
    function ChangeReviewValue(strValue, fieldName)
    {
    	var d = document.FormMain;
    	
    	if(strValue == true) 
                    'set the value of the document.FormMain.(fieldName Passed).value = 2
    		d[fieldName].value = 2;
    	else
                    'set the value of the document.FormMain.(fieldName Passed).value = 0
    		d[fieldName].value = 0;
    }
    </script>
    </head>
    
    <body>
    <form name="FormMain" method="post" action="">
    <table width="75%" border="0">
      <tr>
          <td><input type="checkbox" name="chkReviewed" value="Reviewed_{7hd6-38dh-d83k-93j3}" onClick="ChangeReviewValue(this.checked, this.value);">&nbsp;Reviewed</td>
        <td><input type="hidden" name="Reviewed_{7hd6-38dh-d83k-93j3}" value=""></td>
      </tr>
      <tr>
          <td><input type="checkbox" name="chkReviewed" value="Reviewed_{3jd8-ke8d-o3jd-893jd}" onClick="ChangeReviewValue(this.checked, this.value);">&nbsp;Reviewed</td>
        <td><input type="hidden" name="Reviewed_{3jd8-ke8d-o3jd-893jd}" value=""></td>
      </tr>
    </table>
    </form>
    Last edited by Memnoch1207; Dec 11th, 2003 at 11:47 AM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    I haven't tested the script but at first sight you've got your comments wrong. Unlike VB comments are started with // in javascript. Or you can use a multiline comment which starts with /* and ends with */.
    Try sorting that, then reply if you still have problems.
    Have I helped you? Please Rate my posts.

  3. #3
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    Another thing:
    I'm not sure about this (some1 else should maybe check up on this), but I think that some browsers don't like hidden text fields. Either make it's style visbility=hidden, or place is in a hidden DIV.
    Have I helped you? Please Rate my posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width