This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Dynamic inputs are not getting read by the request

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm creating some text and hidden inputs on a page dynamically. However, when the page is getting submitted, the objects are not in the request.

Why would the objects not be on the request after the page gets submitted?

The objects are within the form tags.

Below is an example of how I'm setting an input on the page.

var tableBody = document.getElementById('line');
var input1 = document.createElement('INPUT');
var something = 'something';
var somethingValue = 'something value';
input1.setAttribute('type', 'hidden');
input1.setAttribute('name', something);
input1.setAttribute('value', somethingValue);
tableBody.appendChild(input1);
 
Sheriff
Posts: 67651
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This hasn't anything to do with JSP, so moving it to the HTML/Javascript forum.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you have to create tr and td

var tr=tableBody.appendChild(document.createElement("tr"));
var td=tr.appendChild(document.createElement("td"));
td.appendChild(input1);
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what does a table have to do with it?

Are you seeing a problem in IE? With Firefox or Mozilla?

Eric
 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
srilatha kareddy, I'm pretty sure, a hidden input doesn't have to be in a td.

Eric Pascarello, it works with IE, but not FireFox.
 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have go another route to implement this since IE does not support the class or style attributes when creating objects and setting the attributes, in the manner I listed previously. Having the page look bad is not an option. I will have to go to the server, save the information, then re-display the page, instead of just adding new rows, then saving once when complete.

Thanks for taking the time to look at my problem.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was expecting you to say it worked in FF and not IE. There goes my solution. lol

with IE it really does not support setAttribute

I normally set things with

newElement.className = "something";
newElement.value = "qwerty";

where are you appending this new hidden element? Any errors in the JavaScript console in Firefox? If you change it to a normal textbox, does it appear on the webpage?

Eric
 
Craig Dumolien
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric, I had no errors in the javascript console. Everything appeared as I expected, in FireFox

I did change the attribute of the hidden fields to text, so that I could see them, and they showed where I expected them to.

I had the hidden fields in a <tbody> tag, then when srilatha comment, I moved them into a <td> tag. That did not help either.

I hate to waste your time on this further. I am taking another route to accomplish the same thing. It will be easier to code in the long run, but the user will have to wait for an extra post.

Thank you for your time and effort.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do not append them to the table body, instead append them to the form and see if that helps.

If it is hidden, it does not matter where you put them. I think FF has a problem with the location of the append.

Eric
 
reply
    Bookmark Topic Watch Topic
  • New Topic