• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

HTML/JavaScript: user defined number of textboxes help

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I'm trying to write a HTML for where by the user can input info and said info is printed to a .txt and saved.

I'm having trouble with some aspects of the form itself.

I have the basics worked out (I think) and any help on this will be appreciated!!!

So now to the problem:

1) I want the user to be able to select a number of times the code below is expressed.

d: <input type="text" name="hnmr_shift1" />
H's: <input type="text" name="h_s1" />
Multiplicity: <input type="text" name="multiplicity1" />
J coupling:<input type="text" name="j_coupling1" /> <br />

so if the user say selects 3 from a drop down menu or whatever then it will return something like this;

d: (textbox) H's: (textbox) Multiplicity: (textbox) J coupling: (textbox)
d: (textbox) H's: (textbox) Multiplicity: (textbox) J coupling: (textbox)
d: (textbox) H's: (textbox) Multiplicity: (textbox) J coupling: (textbox)


the inputs will then be printed to a text file using JavaScript(most likely) so that needs to be accounted for.

I want to avoid using php (or anything that requires apache or something similar to run) the idea of this HTML form is that it can be passed around and used without having to install anything or gain permissions etc. as it will be used in a school environment.

Thanks again

Aaron

 
Marshal
Posts: 67447
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create the new elements via JavaScript DOM manipulation.

This would be a a lot easier with a JavaScript library such as jQuery. And even easier with the client-side templating plugin.
 
Aaron Rizzle
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Bear

Will look into it.

Anyone know it its possible to maybe have an "add row" button whereby the text box will be given a new id each time (something like "a" + 1 etc.) I add a new row ?

i.e

d: (textbox id=hd1) H's: (textbox id=hs1) Multiplicity: (textbox id=hmult1) J coupling: (textbox id=hj1)
d: (textbox id=hd2) H's: (textbox id=hs2) Multiplicity: (textbox id=hmult2) J coupling: (textbox id=hj2) button(add row and id each box as previous id + 1)


I suppose I could then use javascript to getElementById, save as var and print as per usual.


Cheers

Aaron

Some code to play with would also be awesome

Thanks again

 
Oh sure, it's a tiny ad, but under the right circumstances, it gets bigger.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic