Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Prefer table(dateformat,papersize,enablepass,currency)
params table(newpassword,oldpassword,dateformat,papersize,enablepass,currency,secretq,secretans)

These are the two tables I am working with.Prefer table details insertion is done in prefer.js and params table in params.js.On insertion the datas are inserted like.
for example:
prefer
dateformat ,papersize ,enablepass ,currency
dd/mm/yy , 4 , yes , $

params table appears like this:-
newpassword ,oldpassword, dateformat , papersize, enablepass , currency, secretq , secretans
qwer , asdf , - , - , - , - , dfg , dgdfg
- , - , dd/mm/yy , 4 , yes , $ , - , -

the dateformat,papersize ,enablepass and currency is inserted in another line:-my code says to do the same, I need to know how to insert the fields together in one line?
something like this:-

params table:-
newpassword, oldpassword, dateformat , papersize , enablepass , currency, secretq , secretans
qwer , asdf , dd/mm/yy , 4 , yes , $ , dfg , dgdfg

prefer.js

SQL
db=openDatabase(masterDbName,version,displayName,maxSize);
    db.transaction(function (tx)
    {
   tx.executeSql('INSERT INTO preferences(date_format,paper_size,currency_symbol,password)VALUES(?,?,?,?)',[$('.date option:selected').val(),$('#paper_size').val(),$('.currency option:selected').val(),$('.password option:selected').val()],populate_success,transaction_error );
     tx.executeSql('INSERT INTO params(date_format,paper_size,currency_symbol,enable_pword)VALUES(?,?,?,?)',[$('.date option:selected').val(),$('#paper_size').val(),$('.currency option:selected').val(),$('.password option:selected').val()],populate_success,transaction_error );
    });


params.js

db=openDatabase(masterDbName, version, displayName,maxSize);
db.transaction(function(transaction)
{
transaction.executeSql('insert into params(new_password,old_password,secret_question,secret_answer)values(?,?,?,?)',[ $('#pass1').val() ,$('#pass2').val(),$('#question').val(),$('#answer').val()],populate_success,transaction_error );
});

I hope the question is clear by my words..please help
Posted
Updated 25-May-14 18:42pm
v2
Comments
Sergey Alexandrovich Kryukov 26-May-14 1:34am    
Are you sure you want to do it in Javascript? It could be utterly unsafe, because the script it totally opened to the client and can be easily spoofed. How about using one of the server-side technologies.
—SA
p@y@l 26-May-14 2:01am    
I am using html also for design in this, but database work is completely done in javascript,and my work to be done in this!!Which other you are talking about?

1 solution

Done with it..it is just u have to update the filed instead of inserting again!

SQL
db=openDatabase(masterDbName,version,displayName,maxSize);
   db.transaction(function (tx)
   {
  tx.executeSql('INSERT INTO preferences(date_format,paper_size,currency_symbol,enable_pword)VALUES(?,?,?,?)',[$('.date option:selected').val(),$('#paper_size').val(),$('.currency option:selected').val(),$('.password option:selected').val()],populate_success,transaction_error );
    tx.executeSql('UPDATE params SET date_format=?,paper_size=?,currency_symbol=?,enable_pword=?',[$('.date option:selected').val(),$('#paper_size').val(),$('.currency option:selected').val(),$('.password option:selected').val()],populate_success,transaction_error );
   });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900