Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Different Form for Add Record

Locked
vario
Posts: 148
Joined: Mon Dec 05, 2011 12:23 pm
Location: Newton Abbot, UK
Has thanked: 1 time
Been thanked: 1 time

Different Form for Add Record

Unread post 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!
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Different Form for Add Record

Unread post 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
vario
Posts: 148
Joined: Mon Dec 05, 2011 12:23 pm
Location: Newton Abbot, UK
Has thanked: 1 time
Been thanked: 1 time

Re: Different Form for Add Record

Unread post 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
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Different Form for Add Record

Unread post by admin »

.
Locked