i have a div values that i want to hide and then pass its value into form
I tried this below. any help
Code:<div id="records" type="hidden"> <input type="text" name="records" value="records"> </div>
i have a div values that i want to hide and then pass its value into form
I tried this below. any help
Code:<div id="records" type="hidden"> <input type="text" name="records" value="records"> </div>
Unfortunately you can't pass div values (there isn't such a thing) - you'd pass the input as a hidden field instead;Here you are only passing the word "records" though, which may be correct, but it's also likely that you'd want to pass a dynamic variable via php for example;Code:<input type="hidden" name="records" value="records">Code:<input type="hidden" name="records" value="<?php echo $records;?>">
Focus on Function Web Design
Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps
Element div cannot technically have value or type properties. And you cannot pass the value of any of its valid properties without javascript or perhaps server side code (only by copying). You have posted (or someone else has moved the post) to the HTML section, so it's hard to understand what language you intend to do this in. Could you be more specific about what you're trying to accomplish and using what language?
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
If you have the need to submit content rendered inside a <div> element along with other form elements try this.
For every <div> a <textarea> is created and filled with the inner HTML of the div. The name attribute for the <div> is id of the form+'div'. The value of the id attribute of the above mentioned <div> will be used as the name attribute of the <textarea>
Code:<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <form id="form" name="formname" action="index.html" method="get" onsubmit="div2form('form')"> <input id="i1" name="i1name" type="text" value="10"> <div id=t1 name="formdiv">sdajda;lkdja;ljdal;dj</div> <div id=t2 name="formdiv">aaaaaaaaaaaaaaaaaaaaaa</div> <input type="submit" name="submit" value="submit"> </form> </body> <script type="text/javascript" > function div2form(id){ var form=document.getElementById(id); if(!form){ return; } var divs=document.getElementsByName(id+'div') var i, ndivs=divs.length; for(i=0;i<ndivs;i++){ if(document.getElementById('textarea'+divs[i].id)){ document.getElementById('textarea'+divs[i].id).value=divs[i].innerHTML; } else { var texta=document.createElement('TEXTAREA'); texta.name=divs[i].id; texta.id='textarea'+divs[i].id; texta.value=divs[i].innerHTML; texta.style.display='none'; form.appendChild(texta); } } } </script>
Bookmarks