Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Javascript DOM Problem

Featured Replies

Hello,

 

I am coding a contact form with multiple file attachments, I've run into some problems with the presentation and was wondering if you guys had any solutions.

 

The page in question is: http://www.tempusphoto.co.uk/contact-test.html

 

I am calling a javascript function that creates a child div with a 'file input box' in it and adds it to the parent div (called "content").

 

I need to use divs, so I can allow users to remove the file input boxes.

 

The problem is that the divs are placed underneath the submit box.

 

Is there a way I can reposition the submit box and the text below it when boxes are added, so that they are added above the submit box + text

I see you have that function "addAttachBox" that does this:

....
document.getElementById('content').appendChild(newdiv);
....

 

Instead of appending to #content, why don't you place a #something div inside the form right after attachments ? Then you can have:

....
document.getElementById('something').appendChild(newdiv);
....

  • Author
Instead of appending to #content, why don't you place a #something div inside the form right after attachments?

 

Hi there, I've tried that before posting here ... didn't have much success:-

 

This is the XHTML code:

<tr>
  <td class="label">Attachments:</td>
  <td class="element">
  <input type="file" name="filename1"> <a href="java script:;" onClick="addAttachBox();...													
</tr>

<div id="boxcontainer"></div>

 

Javascript changed to:

document.getElementById('boxcontainer').appendChild(newdiv);

 

and the result:

http://www.tempusphoto.co.uk/contact-test.html

It should be something like this:

<tr>
  <td class="label">Attachments:</td>
  <td class="element"><input type="file" name="filename1"> <a href="java script:;" onClick="addAttachBox();">Add Attachments</a></td>
</tr>


<tr><td colspan="2">
		<div id="boxcontainer">						
		</div>
</td></tr>



<tr>
  <td><input type="hidden" name="counter" value="1" /></td>
  <td><input id="normal" type="submit" name="Submit" value="Submit" /></td>
</tr>

The boxcontainer div should be on a row inside the table you already have.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.