Page 1 of 1

Different Form for Add Record

Posted: Fri Dec 30, 2011 6:06 pm
by vario
I have a table of transactions which I load into the database from a CSV file weekly, assigning a php uniqid() as I go. The user is allowed to modify one field only so I have set the other edit screen fields to readonly. However I would like the user to be able to add new records via the "Add Record" button on the browse form. I am experimenting with Javascript (after browsing the form source) to modify the element class from "readonly" to "objects", but is this the way to acheive the result?
I am new to Javascript and PHP!

Re: Different Form for Add Record

Posted: Fri Jan 06, 2012 3:38 am
by admin
vario,

Using nuLoadThis()

http://wiki.nubuilder.com/tiki-index.ph ... uLoadThis_

you could have all fields starts as editable and then do this..

Code: Select all


function nuLoadThis(){

   if(document.getElementById('recordID').value != '-1'){  // '-1' means a new record
      document.getElementById('field1').disabled=true;
      document.getElementById('field2').disabled=true;
      document.getElementById('field3').disabled=true;
   }

}


Steven

Re: Different Form for Add Record

Posted: Thu Jan 19, 2012 1:32 pm
by vario
Steven,

Thanks for this. After some browsing of the form source code and a certain amount of Googling I had also tried using these two functions:

document.getElementById('ftx_tran_date').class='objects'
document.getElementById('ftx_tran_date').removeAttribute('readonly')

I like your solution as it involves less code!

vario

Re: Different Form for Add Record

Posted: Mon Jan 23, 2012 4:59 am
by admin
.