Coldfusion checkbox question

Page 1 of 1

1 Replies - 1552 Views - Last Post: 06 August 2008 - 07:33 AM Rate Topic: -----

#1 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Coldfusion checkbox question

Posted 31 July 2008 - 06:53 AM

Hey Everyone,

well last few days i been trying to figure this out an i cant seem to.

ok on the first page i have a form that someone fills out an theres a checkbox. if it is checked it is true, if it is not it is false. Then you submit the information an it goes all into the database.

You are then taken to a second page where you see the exact same form from the first page again, except you see what you had typed in on the first page on the second page. On the second page you basically just see what you typed in before an if you notice a spelling error or if you selected something you shouldn't of you fix it an then click the update button an it updates the database.

The problem i am having is with my check box. When i fill it out the first page an submit it, it works correctly. However, when i try to make updates to it on the second page is when i run into problems. What happens is, is if i enter a value that is true on the first page an then try to change it on the second page to false it wont. It will remain true. If i submit it as false an then change it to true it will go true, but if i try to change it back to false it will remain true. Here is my code

the checkbox on the first page
<input type="checkbox" name="htpp" value="1"/>


the check box on the second page
<cfparam name="Form.htpp" default="0">
<input type="checkbox" name="htpp" value="1" id="htpp
<cfif #form.htpp# eq "1">checked=yes</cfif>


i have tried to take the value="1" out of the second page, but if i do that then it screws up the update saying that there is no value for that field an wont submit.I have tried changing the value to 0 an when i do that if i enter a value of true an change it to false it will do it, but if i try to change it to true from false it will remain false.

Thanks you to all who help,
Rachel

Is This A Good Question/Topic? 0
  • +

Replies To: Coldfusion checkbox question

#2 bonneylake  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 22-July 08

Re: Coldfusion checkbox question

Posted 06 August 2008 - 07:33 AM

Well i figured out the resolution to my own problem. Basically the ajax script i was using was causing me the trouble. The link to it is this http://www.captain.a...ost-request.php.

but basically theres a part in there code that looks like this

 function get(obj) {
	  var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) +
					"&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );
	  makePOSTRequest('post.php', poststr);
   }


but anyway as long as you leave it .value it will send a value no matter if its true or false. So all i had to do
was change .value to .checked and worked, they said you would apply this to a radio button as well.

but just wanted to post this in case someone else runs into a similar problem as me.

Thank you,
Rach
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1