Tizag Webmaster Forums  

Go Back   Tizag Webmaster Forums > Web Development > Client-Side Scripting Forum > JavaScript Forum

Reply
 
Thread Tools Display Modes
  #1  
Old 11-03-2009, 11:34 AM
rizz rizz is offline
Newbie
 
Join Date: Nov 2007
Posts: 34
rizz will become famous soon enough
How to get the input elements by basing on the formid?

Hi, may i have some idea please on how would i get input elements by just basing on form id?

In my example there are 2 forms with different form name and form id. The first one, form name and id is formm1. Second is form2. My problem is how would i get the length of dtlid[] in form1 and form2?
So basically when i click submit form1 or form 2 i will get the length of form1 dtlid[] so i would know which qty textfields has a value. Any idea please, how it is done?
HTML Code:
<div>
<form method="post" name="formm1" id="formm1" action="#">
        <input type="hidden" name="mainid" value="M01">
	<input type="hidden" name="dtlid[]" value="23"><input type="text" name="qty[]">
	<input type="hidden" name="dtlid[]" value="30"><input type="text" name="qty[]">
	<input type="hidden" name="dtlid[]" value="31"><input type="text" name="qty[]">
	<input type="submit" name="submit" value="submit">
</form>
</div>

<div>
<form method="post" name="formm1" id="formm2" action="#">
        <input type="hidden" name="mainid" value="M01">
	<input type="hidden" name="dtlid[]" value="60"><input type="text" name="qty[]">
	<input type="submit" name="submit" value="submit">
</form>
</div>
i have purpose why it is in a different forms. Basically the form is dynamic, it is dependent on the database
Reply With Quote
Sponsored Links
  #2  
Old 11-03-2009, 02:54 PM
greatstar00 greatstar00 is offline
Graduate Student
 
Join Date: Sep 2007
Posts: 881
greatstar00 has a spectacular aura aboutgreatstar00 has a spectacular aura about
in each form, have an extra input field
like this
<input type="hidden" name="form_name" value="formm1" />
so, u would know which form is being submitted
__________________
Free webspace to test php/mysql (keep backup)
MySQL Host: sql305.0lx.net >FTP Server: ftp.0lx.net >DB name: 0lx_4217081_testdb
FTP/SQL User: 0lx_4217081 >FTP/SQL Password:123456
Website URL: use4free.co.cc (upload to folder "htdocs")
Reply With Quote
  #3  
Old 11-03-2009, 08:40 PM
alanphp's Avatar
alanphp alanphp is offline
Graduate Student
 
Join Date: Nov 2008
Location: USA
Posts: 797
alanphp has a spectacular aura about
Send a message via Yahoo to alanphp
hidden inputs are bad.
javascript can change the values.
__________________
HTML,CSS,PHP,Javascript,jQuery,AJAX,mySQL and a very fast typer for Google. Just ask me. Please +rep me if I helped you. Thanks!
Join my new game!
Reply With Quote
Reply

Thread Tools
Display Modes

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


All times are GMT -6. The time now is 04:20 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 2008, Tizag