943,827 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1771
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 12th, 2009
0

customised the locked textboxes and save as new data

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009
Jun 12th, 2009
0

Re: customised the locked textboxes and save as new data

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
PHP Syntax (Toggle Plain Text)
  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
Reputation Points: 13
Solved Threads: 15
Junior Poster in Training
Tulsa is offline Offline
77 posts
since May 2009
Jun 12th, 2009
0

Re: customised the locked textboxes and save as new data

Click to Expand / Collapse  Quote originally posted by Tulsa ...
<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:
html Syntax (Toggle Plain Text)
  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
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007
Jun 13th, 2009
0

Re: customised the locked textboxes and save as new data

hi
sorry atil ....
i post onblur() event here it's my mistake
thanks for that
Reputation Points: 13
Solved Threads: 15
Junior Poster in Training
Tulsa is offline Offline
77 posts
since May 2009
Jun 13th, 2009
0

Re: customised the locked textboxes and save as new data

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
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009
Jun 13th, 2009
0

Re: customised the locked textboxes and save as new data

>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?
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jun 13th, 2009
0

Re: customised the locked textboxes and save as new data

Click to Expand / Collapse  Quote originally posted by tulipputih ...
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-
Quote ...
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..
Quote ...
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
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009
Jun 13th, 2009
0

Re: customised the locked textboxes and save as new data

Let's see your code.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jun 13th, 2009
0

Re: customised the locked textboxes and save as new data

Click to Expand / Collapse  Quote originally posted by adatapost ...
Let's see your code.
ok..thanks.this is my code
php Syntax (Toggle Plain Text)
  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. ?>
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009
Jun 13th, 2009
0

Re: customised the locked textboxes and save as new data

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.
javascript Syntax (Toggle Plain Text)
  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:
html Syntax (Toggle Plain Text)
  1. <input doEnable="yes" .../>
javascript Syntax (Toggle Plain Text)
  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.
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Warning: session_start() [function.session-start]: Cannot send session cache limiter
Next Thread in PHP Forum Timeline: auction script





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC