3 Replies - 842 Views - Last Post: 29 March 2010 - 02:54 PM

#1 Guest_Sethcran*


Dynamically adding html elements

Posted 28 March 2010 - 04:03 PM

I'm not at all sure that this is the right forum for this question, but then again, it covers a few different languages and such, and so my apologies if this is in the wrong place.

In a project for my databases course, we have to develop a website that links with the database. In this class we've covered SQL, Java, and JSP, which we are supposed to use for this project. Most of the SQL/Java stuff I am fine with, and have already done several bits of it ( It's a pretty large project, due at the end of the semester ).

The issue I am having is currently I have to create a page for orders. Now, the user can order more than 1 thing at a time, so I currently have the different things he can order in a drop down box ( I know, not incredibly realistic, but unless I get the time to go for a full shopping cart, not sure if I'm going to bother with it, since the class and the project is about databases, not how our website looks. Anyways, I want to have a link in the form to add another element ( that withdraws information from the database ), so that the user can select any number of things to order. For this I need to dynamically modify the html of the page, but since this class hasn't covered html, I am unsure how to do this with html, and even with jsp, at least to the degree that I am looking for.

I've done some searching around and seen that this is possible with Javascript, but I know next to nothing about it, and it certainly isn't covered in the course. Is it possible to add elements like this with JSP/Html, or must I use something like JS? Either way, I am unsure of how to go about doing it. Any pointers on getting me on the right track to being able to do this, would be lovely <3. Note: I'm not really looking for the codeto do this, as I like to learn things myself, but some outline of how to go about it would be awesome.

Just to be clear what I am trying to do exactly: I have a drop down menu, and the options from the menu are taken from my database. I know how to do this part already. What I want to be able to do, is duplicate this section of code each time the user presses a button to add another, so that I can have a variable number of drop down elements based on how many different items the user wants to buy. I also need to be able to insert these values into the database ( which I also am fine with doing ), but I am unsure how to get a unique id for each of these generated forms, so that I can send the appropriate information to the database server.

If I need to clear up anything, or you have questions about what I am asking, then please, feel free to ask <3.

Is This A Good Question/Topic? 0

Replies To: Dynamically adding html elements

#2 Guest_Sethcran*


Re: Dynamically adding html elements

Posted 29 March 2010 - 11:26 AM

Friendly bump <3
Was This Post Helpful? 0

#3 jrm402  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 52
  • View blog
  • Posts: 333
  • Joined: 18-March 10

Re: Dynamically adding html elements

Posted 29 March 2010 - 12:30 PM

I don't know JSP and I know a little Java from high school, but I would say Javascript is the way to go with your project.

I've began my learning in Javascript, MySQL, and PHP from W3Schools.com. Here is the Javascript tutorial link. It should give you a basic knowledge of what you need to begin searching for more information (unless it's enough for you to complete your project).

I'm not exactly sure what you're trying to do, but I would focus heavily on the events section -- primarily onsubmit, and onchange.

Good Luck!
Was This Post Helpful? 0
  • +
  • -

#4 BigRicke  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 18
  • Joined: 11-March 10

Re: Dynamically adding html elements

Posted 29 March 2010 - 02:54 PM

Try using AJAX (Asynkron Javascript och XML). The page will be more dynamic and you don't have to reload the page when you what some information from the database.
I'm not exactly sure what you want to do but if I understand your question correctly ajax should be able to help you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1