SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Gathering HTML for a div

    Hi friends,
    Am looking for some solution for my problem. Hoep someone can guide me.
    Lets say i have a code like this

    HTML Code:
    <div id="test">
    	asdflkajdlfkajldkf
    	<input type="button" name="click" value="Button 1" />
    	<input type="text" value="1234" name="text" />
    </div>
    
    <input type="button" name="testBtn" value="click me" onclick="alert(test.innerHTML)" />
    once i click on the button, it shows me the innerHTML of the div "test" - which is what i need. But once i change the content of the textbox, it does'nt reflect in the innerHTML. I am looking to store the content of this <div> into the database along with the changes made.

    Thanks

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you just use a normal form submit to save the textarea content to the database? No need to use innerHTML...

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply buddy
    i do not want to submit anything, i just want to have a popup <div>, let the user enter the information and i want to post it via ajax, saving the whole html from the <div> in the background.

    Any help please?

    Thanks

  4. #4
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up U cant get TextField and text area values by innerHTML

    The solution is that just get the vlaues of the text field seprate using its ID or name using its value property.
    and
    concat it with the innerHTML
    or
    replace value="" of text field with value="{text field value here}" and send it to server via AJAX.

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mudassar_ijaz for your reply
    but, i would really like to save the html as it is exactly - the html could be dynamic, something like templates - this is the project am doing
    its a lab based system, where there are different specimens - each kind of specimen has its own properties. What i would like to do is having a standard template kind of html for each specimen, when the user types in information, i just store exactly as they typed it - to show it in future. It would be quite hard for me to go through the html elements for each type of so called template.
    Hope some body can provide me with a quick and dirty solution, like being able to grab the innerHTML of the <div> tag along with the typed in content.

    Thanks

  6. #6
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mudassar_ijaz
    i do realize that i can't get the values from the innerHTML. Is there any script that could do this for me? All i need is to be pointed in the right direction.

    Thanks


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
  •