techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old Dec 24, 2010, 07:06 PM   #1
ct5098
5 Posts
 
Join Date: Aug 2009
Posts: 13 (0.01/day)
Thanks: 0
Thanked 0 Times in 0 Posts

System Specs

HTML DOM, Javascript Question

I'm creating a web-based inventory management system for a computer repair store. I want to have the user click a button and create a form underneath the button. If I create the form via Javascript with createElement, appendChild, etc. will I be able to access the ids within the newly created form and provide client-side validation with Javascript? Right now I'm using AJAX to get the form from a PHP script where I just echo the HTML code; then I just use innerHTML to insert the code onto the page. I can't use Javascript to validate the form the way I do it now.
ct5098 is offline  
Reply With Quote
Old Dec 24, 2010, 07:22 PM   #2
temp02
200 Posts
 
Join Date: Mar 2009
Posts: 490 (0.32/day)
Thanks: 0
Thanked 171 Times in 158 Posts

How about setting the default size of the Form to 0 (CSS height) and when the button is pressed the form is shown (height property removed or returned to default size, you could even animate the sucker if you want)?
As for the validation it has to occur in the server when the POST of the form is submited, you could validate it with javascript but some smartguy could still submit "wrong" values.

Please note that it has been a while since I've messed with any web stuff :P.
temp02 is offline  
Reply With Quote
Old Dec 24, 2010, 07:29 PM   #3
ct5098
5 Posts
 
Join Date: Aug 2009
Posts: 13 (0.01/day)
Thanks: 0
Thanked 0 Times in 0 Posts

System Specs

I was thinking of doing something with CSS, except with the visibility property. Wil this work if I just change the visibility of the form to hidden and then visible? I was only just starting to learn AJAX and I just wanted to use it to see how it would work.
ct5098 is offline  
Reply With Quote
Old Dec 24, 2010, 07:33 PM   #4
temp02
200 Posts
 
Join Date: Mar 2009
Posts: 490 (0.32/day)
Thanks: 0
Thanked 171 Times in 158 Posts

AFAIK yes you can change the css "visibility" property to "hidden" or "visible" and the form should act accordingly.
It's easier this way, since it's just one or two lines of Javascript to show and hide the form.
temp02 is offline  
Reply With Quote
Old Dec 24, 2010, 07:36 PM   #5
ct5098
5 Posts
 
Join Date: Aug 2009
Posts: 13 (0.01/day)
Thanks: 0
Thanked 0 Times in 0 Posts

System Specs

Ok, thanks for your help. I always try to do things the hard way
ct5098 is offline  
Reply With Quote
Old Dec 24, 2010, 07:52 PM   #6
W1zzard
Benevolent Dictator
 
W1zzard's Avatar
 
Join Date: May 2004
Location: Stuttgart, Germany
Posts: 13,869 (4.17/day)
Thanks: 184
Thanked 10,450 Times in 3,218 Posts
Send a message via ICQ to W1zzard Send a message via AIM to W1zzard Send a message via MSN to W1zzard Send a message via Skype™ to W1zzard

System Specs

if the form is static you should hide it via css visibility

if you need to generate its contents on user action, use ajax to generate the html code and insert it in appropriate position, this should update the DOM tree.

dont forget about server side validation. never ever trust the client with anything, it's incredibly easy to modify/remove/generate html and js code


personally i avoid js whereever possible or at least make sure there's a decent fallback for client without js enabled that makes sure everything stays usable
W1zzard is online now  
Reply With Quote
Old Dec 24, 2010, 08:01 PM   #7
ct5098
5 Posts
 
Join Date: Aug 2009
Posts: 13 (0.01/day)
Thanks: 0
Thanked 0 Times in 0 Posts

System Specs

Yes, the form is static. I am going to have to validate with PHP as well trio check the MySQL database to ensure no duplicate entries, etc. Thanks for the responses.
ct5098 is offline  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Official HTML(4,5) and javascript users help thread. Braveheart Programming & Webmastering 11 Dec 21, 2009 05:32 PM
some html php and mysql mixed question r9 Programming & Webmastering 2 Aug 30, 2009 04:24 PM
quick HTML question Braveheart Programming & Webmastering 3 Jul 5, 2009 08:42 AM


All times are GMT. The time now is 03:18 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
no new posts