Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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

writing contents to a text area or hidden field

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
using Javascript functions, i have created a set of XML tags that
are generated on a new window. ie in my form, the user makes his
selection using the select tags. once these selections are made, using
an appropriate function, i create a set of XML tags that are generated
in a new window. the XML tags are as below:

<user>
<pic>C:\My Documents\abc.jpg</pic>
<tex>C:\My Documents\dat.txt</tex>
</user>

now i want to submit these tags to a server side program ie a
servlet/JSP. i feel i can write that XML to a form field (say, a
textarea, or a hidden field) and then submit that.
but i am not sure how to proceed. how can i write the above XML
onto a textarea or hidden field. it will quite helpful to me if u can
help with some sample code,
thanks in advance,
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add information to text area, hidden element, or text field by setting the value.

document.FormName.ElementName.value = "blah";

You may also want to look into escaping the string.
escape()

Not sure that is what you are asking, but that is what I can come up with after writing all night and about to go to bed.

Eric
 
Sri Sar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi eric,
i will try to make my problem clearer:
1) by using a form, the user selects options like an image, a text file etc
2) in the same form, i use a javascript function that geneates an XML like structure representing the values chosen by the user( say the user has chosen an image abc.jpg and a text file dat.txt). after the user has chosen his selections and clicks on an appropriate button, a new window opens.
3) this window contains XML tags that denote the files chosen by the user:
<user>
<pic>C:\My Documents\abc.jpg</pic>
<tex>C:\My Documents\dat.txt</tex>
</user>
4) now i want these XML tags to be written into a hidden field so that when the user clicks on the submit button, a server-side program on the server can get these tags.
my query is that how can i include all the tags into a hidden field??
hope i have made the question clear.
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way you described it, I hope following can help:
You could write another function that would ask the user for a confirmation of the choices made with a "proceed" button that when clicked would send the choices to the server in a separate file... instead of opening a new window for the confirmation for example...
 
We find this kind of rampant individuality very disturbing. But not this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic