Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread Display Modes
Old Sep 7, 2008, 09:53 AM   #1
macrumors newbie
Join Date: Aug 2008
Adding/Removing an Extra Field using Javascript

Hi everyone. I am attempting to do the following:

1. Click a button
2. It adds a element to the page (such as a text box)
3. Then when the user clicks another button, the element is removed, and replaced with another element

However, I just don't know where to start on this one.

Thanks for any help.
pierce111 is offline   0 Reply With Quote
Old Sep 7, 2008, 11:49 AM   #2
Moderator emeritus
angelwatt's Avatar
Join Date: Aug 2005
Location: USA
This is essentially what a tabbed layout does (at least when it stays on one page). That might give you something to work from for searching out code.

[HTML]<div id="buttons">
<input type="button" value="Add" onclick="ShowZone('zone1')" />
<input type="button" value="Change" onclick="ShowZone('zone2')" />

<div id="zones">
<div id="zone1">
<p>Text in zone 1.</p>
<div id="zone2">
<p>Text in zone 2.</p>

#zone1, #zone2 {
 display: none;
PHP Code:
function ShowZone(z)
zones document.getElementById("zones").getElementsByTagName("div");
  for (var 
x=0y=zones.lengthyx++) {
zones.[x].style.display "none"// vanish all zones
// make zone z appear
document.getElementById(z).style.display "";

Hopefully this is enough to get you started. Let me know if you need further guidance.
angelwatt is offline   0 Reply With Quote

MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Have you ever added an extra line although you don't need it to get the new iphone?! Ramio iPhone 19 Oct 11, 2011 01:40 PM
Resolved: [Table Views] Adding an extra "new item" row at the end. CodeBreaker iPhone/iPad Programming 2 Sep 29, 2011 10:45 AM
How to remove an extra windows partion from parallels? draggo Mac Basics and Help 0 May 26, 2011 04:19 PM
Use javascript to change <td> background colour based on value in an array dom.mason Web Design and Development 2 May 5, 2010 04:49 PM
Questions about adding an extra HD masterjedi73 Mac Basics and Help 2 Sep 22, 2005 04:17 PM

All times are GMT -5. The time now is 03:56 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC