Jump to content


Photo

html help


  • Please log in to reply
5 replies to this topic

#1 ahalmen

ahalmen
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 27 September 2006 - 08:34 AM

I have a checkbox in html that when checked enables an editor. I want to save the text written in this editor to the db, but il only adds null. Can't figure why. Here's the code

<form name="html_t"><br />&nbsp;HTML Template
&nbsp;<input type="checkbox" name="html" id="html" onchange="show_hide(html);" />
</form>
<div id="div_editor" style="display:none;">
<form name="editor">
    <textarea name="html_content" id="html_content" cols="50" rows="10"></textarea>
        </form>
</div>

and here is the js

function show_hide(chck){
  if(chck.checked==1){
    document.getElementById('div_editor').style.display = "";
  }
  else{
    document.getElementById('div_editor').style.display = "none";
  }
}

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 27 September 2006 - 10:04 AM

You need a submit action for the form pointing to an appropriate script to perform the transaction.

You also do not need two forms in there - just have the one.

follow me on twitter @PHPsycho

#3 ahalmen

ahalmen
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 27 September 2006 - 11:30 AM

I already have a submit form, because besides that textarea I have another one that is not triggered by a checkbox, and I can see that value and add it to the database. I don't know what the problem is.


Thanks,
Andreea

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 27 September 2006 - 06:54 PM

The problem with two forms is that only one submits -- apparently, not the one with the textarea -- so you'll never be able to get that value unless you play with hidden fields.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 ahalmen

ahalmen
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 September 2006 - 06:59 AM

Solved the problem, I just embeded the second form in the first one. Thanks for the help!

Andreea

#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 September 2006 - 02:58 PM

If that works, it shouldn't... nested forms aren't really valid.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users