customised the locked textboxes and save as new data

Reply

Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

customised the locked textboxes and save as new data

 
0
  #1
Jun 12th, 2009
Hi.

How could we unlock the locked textbox whenever users click a button -say ' customise button'.
Then users are able to customise the boxes and save it as a set of new data with new ID?

Help is much appreciated.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 77
Reputation: Tulsa is an unknown quantity at this point 
Solved Threads: 15
Tulsa's Avatar
Tulsa Tulsa is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #2
Jun 12th, 2009
hi
sorry but what you want...
if you want that somebody clicks on button that time textbox enable so you can call javascrit function on button click event
As i posted one example here
  1. <input type="text" disabled="disabled" name="txt1"/>
  2. <input type="button" value="Click me" onblur="func_unlock();">
  3. <script type="text/javascript">
  4. function func_unlock()
  5. {
  6. document.getElementByid('txt1').disabled=false;
  7. }
  8. </script>

Thanks
"Be honest"
"Confidence is everything"
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 358
Reputation: Atli is an unknown quantity at this point 
Solved Threads: 42
Atli's Avatar
Atli Atli is offline Offline
Posting Whiz

Re: customised the locked textboxes and save as new data

 
0
  #3
Jun 12th, 2009
Originally Posted by Tulsa View Post
<input type="text" disabled="disabled" name="txt1"/>
<input type="button" value="Click me" onblur="func_unlock();">
<script type="text/javascript">
function func_unlock()
{
	document.getElementByid('txt1').disabled=false;
}
</script>
Are you sure you don't mean onclick ?
That wouldn't fire when the button was clicked, but rather when the button is deselected.

Edit:
And you misuse the name attribute.
Only IE incorrectly fetches tags via the document.getElementById function based on their name attribute.
You should use the id attribute if your intend to fetch the element using that function.

Like:
  1. <html>
  2. <head>
  3. <title>JS Click Test</title>
  4. <script type="text/javascript">
  5. function EnableBox() {
  6. var box = document.getElementById('disabledBox');
  7. box.value = "";
  8. box.disabled = false;
  9. box.focus();
  10. }
  11. </script>
  12. </head>
  13. <body>
  14. <input id="disabledBox" type="text" disabled="disabled" value="I'm disabled" />
  15. <button onclick="javascript: EnableBox();">Enable</button>
  16. </body>
  17. </html>
Last edited by Atli; Jun 12th, 2009 at 1:29 pm. Reason: Added some stuff
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 77
Reputation: Tulsa is an unknown quantity at this point 
Solved Threads: 15
Tulsa's Avatar
Tulsa Tulsa is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #4
Jun 13th, 2009
hi
sorry atil ....
i post onblur() event here it's my mistake
thanks for that
"Be honest"
"Confidence is everything"
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #5
Jun 13th, 2009
Thanks Tulsa & Atil,
but as far I understand the example you gave is for a specific / one textbox.. Am I right?
What I intend to do is..
1- by clicking 1 button-"customise"..all textboxes will we unlocked
2- and we can update/edit the data in it..
3- subsequently save the data as a new set of data in a database.

I used to do it in VB but as I am a php newbie.. I don't have any ide of it.

Thanks in advanced
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,420
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 430
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: customised the locked textboxes and save as new data

 
0
  #6
Jun 13th, 2009
>Thanks Tulsa & Atil,
but as far I understand the example you gave is for a specific / one textbox.. Am I right?
What I intend to do is..

What are you doing? Tulsa & Atil explained how to enabled or disabled an item? Is there any problem to write a code for another textbox?
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #7
Jun 13th, 2009
Originally Posted by tulipputih View Post
Thanks Tulsa & Atil,
but as far I understand the example you gave is for a specific / one textbox.. Am I right?
What I intend to do is..
1-
by clicking 1 button-"customise"..all textboxes will we unlocked
is it possible to do this in Php? If not..it is ok..I might change my idea..edit the boxes individually & finally save it as a new set of data.

2- and we can update/edit the data in it..
3- subsequently save the data as a new set of data in a database.
Just insert [INSERT INTO] new data in databse, isn't it?
BUt How to update/increase the ID automatically in MySQL database. Logically ID+1, but I do not know the syntax.

Thanks in advanced
Thank you
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,420
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 430
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: customised the locked textboxes and save as new data

 
0
  #8
Jun 13th, 2009
Let's see your code.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: customised the locked textboxes and save as new data

 
0
  #9
Jun 13th, 2009
Originally Posted by adatapost View Post
Let's see your code.
ok..thanks.this is my code
  1. <?php
  2. $query= mysql_query(" SELECT * FROM lesson
  3. WHERE lessonID='" . $_GET['lessonID'] . "'");
  4.  
  5. while($entry=mysql_fetch_array($query))
  6. {
  7. echo " Subject: ";
  8. echo '<input name="subject" readonly="readonly" value="', $entry['subject'] , '" /><br />';
  9. echo " Year:";
  10. echo '<input name="year" readonly="readonly" value="', $entry['year'] , '" /><br />';
  11.  
  12.  
  13. }
  14.  
  15. ?>
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 358
Reputation: Atli is an unknown quantity at this point 
Solved Threads: 42
Atli's Avatar
Atli Atli is offline Offline
Posting Whiz

Re: customised the locked textboxes and save as new data

 
0
  #10
Jun 13th, 2009
If you want JavaScript to enable multiple boxes with one button click, you need to either statically fetch them all (like my example did, but with more than one box), or create a script to fetch all of the boxes you want.

The document.getElementsByTagName could fetch all the input elements for you so you could sort through them and find those you need to enable.
  1. var boxes = document.getElementsByTagName('input');
  2. for(var i = 0; i < boxes.length; i++) {
  3. // Sort through the boxes here.
  4. }

You could give all the boxes that you need to enable a specific attribute to check, like 'doEnable', which you could fetch in your JavaScript code with the getAttribute function.
Like:
  1. <input doEnable="yes" .../>
  1. if(boxes[i].getAttribute('doEnable') == 'yes') {
  2. boxes[i].disabled = false;
  3. }

And P.S.
If you want to send multiple <input> boxes with the same name to PHP, they should be named <input name="name[]" .../> . That way all of them will be sent to PHP as an array, not just the last one in the form.
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC