+ Reply to Thread
Results 1 to 4 of 4

Thread: Javascript help needed

  1. #1
    Tom
    Tom is offline Wannabe Geek Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold
    Join Date
    Jan 2007
    Location
    Kildare, Ireland
    Posts
    245

    Default Javascript help needed

    I'm trying to create some dynamic form fields using javascript. Basically the user enters some text in the new_option text field below and when they click the add_option button it adds a populated text field to a form that is already on the page. Anyone know how to do this off hand?

    Code:
    <input type="text" name="new_option"> <input type="button" name="add_option" value="Add Option" onClick="xxxx">
    
    When button is pressed the new_options are outputed here as addtional text fields which can then be submitted with the main form.
    

    Edit: I've come across an example at http://www.openjs.com/scripts/examples/addfield.php that comes close to what I'm trying to do. Seems like it should work for me, just need to re-write it a bit to suit my needs.
    Last edited by Tom; 23-07-2008 at 02:12 AM.

  2. #2
    louie's Avatar
    louie is offline Senior Member louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough
    Join Date
    Jan 2006
    Location
    Dublin, Ireland
    Posts
    2,328

    Default

    That example is exactly what you are looking for but require small changes to get the value:
    Code:
    //change the function adding an extra field
    function addField(field,area,limit,field_value) { 
    //add value
    input.value = field_value;
    
    :. Web Design & Development Web Design Ireland
    :. Search Engines Optimization Search Engines Optimization
    :. Car Parts & Accessories Car Parts
    :. Cars Ireland Cars Ireland
    :. I Have 2 Find It Directory SEF Directory

  3. #3
    Tom
    Tom is offline Wannabe Geek Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold Tom is a splendid one to behold
    Join Date
    Jan 2007
    Location
    Kildare, Ireland
    Posts
    245

    Default

    Thanks Louie, I've got it working peachy now (almost) after a lot of head scratching and head banging.

  4. #4
    louie's Avatar
    louie is offline Senior Member louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough louie will become famous soon enough
    Join Date
    Jan 2006
    Location
    Dublin, Ireland
    Posts
    2,328

    Default

    if you show us what you have we might be able to improve it for you.
    :. Web Design & Development Web Design Ireland
    :. Search Engines Optimization Search Engines Optimization
    :. Car Parts & Accessories Car Parts
    :. Cars Ireland Cars Ireland
    :. I Have 2 Find It Directory SEF Directory

+ Reply to Thread

Similar Threads

  1. Javascript loop
    By louie in forum Coding Help
    Replies: 13
    Last Post: 01-02-2008, 09:27 PM
  2. Javascript problem
    By ph3n0m in forum Coding Help
    Replies: 1
    Last Post: 21-06-2007, 03:57 PM
  3. javascript
    By 7aken in forum Coding Help
    Replies: 1
    Last Post: 03-04-2007, 03:50 PM
  4. javascript help
    By 7aken in forum Coding Help
    Replies: 2
    Last Post: 20-02-2007, 06:09 AM
  5. Javascript menu bug?
    By ButtermilkJack in forum Coding Help
    Replies: 1
    Last Post: 15-01-2007, 03:21 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Optimization by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64