Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-07-2008, 07:59 PM php + javascript
Junior Talker

Posts: 4
Trades: 0
i need to create a form with javascript add new field function. i`ve the form and it works perfect. now i wonder to pull the javascript value into database using php.

i dont know how to make a code to recognize new field`s id. can someone help me... here i attach my code...

http://scumz.net/neural/product_avai...php?action=add ---> live preview form

http://scumz.net/code/code.txt ---> source code.

form's screenshot = http://easycaptures.com/9515367987

please help me.... im dying...

Last edited by niurexx; 12-07-2008 at 08:02 PM..
niurexx is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-08-2008, 04:09 AM Re: php + javascript
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
now i wonder to pull the javascript value into database using php.
Exactly the same way as you would with a static form. Submit it to a php page (or itself) that reads the form values.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-08-2008, 04:58 AM Re: php + javascript
Junior Talker

Posts: 4
Trades: 0
my prob is, i dont know how.... this is my first time using javascript with php.... i dont know how to recognize the field id....
niurexx is offline
Reply With Quote
View Public Profile
 
Old 12-08-2008, 07:10 AM Re: php + javascript
Skilled Talker

Posts: 85
Name: Ilyes Rhouma
Trades: 0
Hello Niurexx,

I'm not sure about what you mean, but I will answer for what I understand

You want an "Add new field" function,

let's say your fields' names are: input1 , input2 , input3, ...
And as you said, you don't now how much there are because the user will add as he want...

One solution is:
In php read input1, input2, ... in a loop until he get an empty input, so that empty field does not exist, the loop is working from 1 to a maximum number ( 100, or whatever), he get the value of the fields, until one of the values is "" (input n ), so then it exit the loop, easy I think ...
But you need to oblige the user to not keep one field empty ...(not very difficult )

Another solution:
When the user want to write
__________________
Want a cheap and custom programmer or writer ?
Please login or register to view this content. Registration is FREE

Are you
Please login or register to view this content. Registration is FREE
? Start
Please login or register to view this content. Registration is FREE
free and earning money !
Please login or register to view this content. Registration is FREE
Ilyes is offline
Reply With Quote
View Public Profile Visit Ilyes's homepage!
 
Old 12-08-2008, 07:28 AM Re: php + javascript
Junior Talker

Posts: 4
Trades: 0
sorry for my bad english..

ok lets say i put 1 normal input field named test and i want to put its data into tax table and field name test. then for the php code i will use

Code:
$test = sqlesc_$POST([test]);

mysql_query("INSERT INTO tax (test) VALUES($test)") or die(mysql_error());
but now i wat to put data from javascript add new field function. I dont know how....

my javascript code is like this :

Code:
function createNewTax(){
taxCount++;
var newtr = document.getElementById('taxinfotr1').cloneNode(true);
newtr.getElementsByTagName('input')[0].id="taxdesc" + taxCount;
newtr.getElementsByTagName('input')[0].name="taxdesc" + taxCount;
newtr.getElementsByTagName('input')[0].value="";
newtr.getElementsByTagName('input')[1].id="taxpercent" + taxCount;
newtr.getElementsByTagName('input')[1].name="taxpercent" + taxCount;
newtr.getElementsByTagName('input')[1].value="";
newtr.getElementsByTagName('input')[2].id="taxamount" + taxCount;
newtr.getElementsByTagName('input')[2].name="taxamount" + taxCount;
newtr.getElementsByTagName('input')[2].value="";
newtr.id="taxinfo" + taxCount; 
document.getElementById('othertaxtb').lastChild.appendChild(newtr);

var lasttaxtr = document.getElementById('lasttaxtr');
document.getElementById('othertaxtb').lastChild.appendChild(lasttaxtr);
}
the question is, how am i going to put data from that javascript function when user add new field and pu some data in it...? i dont know how...
niurexx is offline
Reply With Quote
View Public Profile
 
Old 12-09-2008, 10:31 AM Re: php + javascript
Junior Talker

Posts: 4
Trades: 0
ok ... i`ve made a code to put one of those 3 fields value into database. field name taxdesc. ok next prob is, i need to put 3 fields in 1 row in a time.

1. taxdesc
2. taxpercent
3. taxamount

and my code is:
Code:
foreach($taxdesc as $description){
  $query = mysql_query("INSERT INTO tax (description) VALUES ('$description')")or die(mysql_error());
 }
anyone can help me please..?
niurexx is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to php + javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.79900 seconds with 12 queries