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

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 7, 2008, 09:53 AM   #1
pierce111
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
angelwatt
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>

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

CSS
Code:
#zone1, #zone2 {
 display: none;
}
JavaScript
PHP Code:
function ShowZone(z)
{
  var 
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

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Adding extra Internal PSU in optical bay for graphics cards [Build log] OrangeSVTguy Mac Pro 34 May 25, 2014 09:37 PM
Mac keyboard adding extra symbols? Really annoying! PVisitors MacBook Pro 2 Nov 26, 2013 11:27 PM
Email address goes to "other" field when adding contact ddublu iOS 6 2 Feb 7, 2013 04:14 PM
Prompted to enter password when adding/removing files from Mac HD Shotgun OS Mac Basics and Help 1 Aug 7, 2012 02:27 AM
Removing Extra Menu Items when Right-Clicking GordanFish Mac OS X 10.7 Lion 3 Jul 5, 2012 05:29 AM

Forum Jump

All times are GMT -5. The time now is 05:46 PM.

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

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