9 Replies - 1824 Views - Last Post: 01 February 2012 - 06:26 AM

#1 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

jQuery dynamic change text

Posted 01 February 2012 - 02:43 AM

Hello, guys i just started learning jQuery and i have to admit its awesome.

However, i want to create something beautiful, but i cant clearly find the correct way doing this.

So, i got a page in which <p> elements are rendered and next to them there is a submit button.
If that button is clicked i would like the html text <p> to turn into editable text[ maybe textfield ? ] and save its new text on the Database.

I would start thaht script by catching an event when the submit button is clicked, but then how am i supposed to turn the html element into other type of element or something like this ?

Any guidance through this would be nice.
Thankkss.

This post has been edited by s0me0ne: 01 February 2012 - 02:43 AM


Is This A Good Question/Topic? 0
  • +

Replies To: jQuery dynamic change text

#2 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: jQuery dynamic change text

Posted 01 February 2012 - 03:07 AM

View Posts0me0ne, on 01 February 2012 - 10:43 AM, said:

So, i got a page in which <p> elements are rendered and next to them there is a submit button.
If that button is clicked i would like the html text <p> to turn into editable text[ maybe textfield ? ] and save its new text on the Database.

I would start thaht script by catching an event when the submit button is clicked, but then how am i supposed to turn the html element into other type of element or something like this ?


Hey there!
If you already have your text in a DB that would make things easier for you, what do you think?
That way you may use an update function.

This post has been edited by Macjohn: 01 February 2012 - 03:08 AM

Was This Post Helpful? 0
  • +
  • -

#3 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

Re: jQuery dynamic change text

Posted 01 February 2012 - 03:13 AM

View PostMacjohn, on 01 February 2012 - 03:07 AM, said:

View Posts0me0ne, on 01 February 2012 - 10:43 AM, said:

So, i got a page in which <p> elements are rendered and next to them there is a submit button.
If that button is clicked i would like the html text <p> to turn into editable text[ maybe textfield ? ] and save its new text on the Database.

I would start thaht script by catching an event when the submit button is clicked, but then how am i supposed to turn the html element into other type of element or something like this ?


Hey there!
If you already have your text in a DB that would make things easier for you, what do you think?
That way you may use an update function.


Yes, i apologise for my bad english.

The text that i render is already saved in the DB. So i just get it and render it. But i would like when the button is clicked that html text to turn into editable text.

Thanks for your fast reply.
Was This Post Helpful? 0
  • +
  • -

#4 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: jQuery dynamic change text

Posted 01 February 2012 - 03:23 AM

No worrys for the english mate, we're here to help not to criticise...

Sure, but besides jQuery, what other language are you using to interact with the DB?
Are you using PHP with MySQL?
Was This Post Helpful? 1
  • +
  • -

#5 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

Re: jQuery dynamic change text

Posted 01 February 2012 - 04:09 AM

View PostMacjohn, on 01 February 2012 - 03:23 AM, said:

No worrys for the english mate, we're here to help not to criticise...

Sure, but besides jQuery, what other language are you using to interact with the DB?
Are you using PHP with MySQL?


No i am writing a module on Drupal CMS which communicates with the DB.
Was This Post Helpful? 0
  • +
  • -

#6 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: jQuery dynamic change text

Posted 01 February 2012 - 05:16 AM

I read a bit about Drupal CMS and is created in PHP and you can use MySQL server.
So I need to know what language are you using( PHP I think is the best for this app), and what DB is your Drupal using...

You answer that and we can probably help you out with it.
Was This Post Helpful? 1
  • +
  • -

#7 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

Re: jQuery dynamic change text

Posted 01 February 2012 - 05:22 AM

View PostMacjohn, on 01 February 2012 - 05:16 AM, said:

I read a bit about Drupal CMS and is created in PHP and you can use MySQL server.
So I need to know what language are you using( PHP I think is the best for this app), and what DB is your Drupal using...

You answer that and we can probably help you out with it.


Yea i am using PHP and mySQL for DB. I thought that only PHP could be used for Drupal. Sorry for that.
Was This Post Helpful? 0
  • +
  • -

#8 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: jQuery dynamic change text

Posted 01 February 2012 - 06:00 AM

(Gonna give you some guide ligns that you can follow, you can allways keep writting here for more help..)
So, I guess you already are familiarized with PHP.
1st option - with different pages

1st - create the page(ex. page1.php) where you have your text with the 'edit' button.
2nd - create a page(ex. page_edit.php) with a textbox where your text(from the db) will fall into.
3rd - in page1 you'll need to retrieve the text from the DB -
SELECT * FROM

4th - in page_edit you'll need to retrieve the text from the DB and putting it in the textbox (the code to do that will almost be the same!
5th - add a button to the edit_page - and create the
UPDATE
function to that action.

I know I'm a bit short in words but just post if there is something that you didn't understand.
I'll be glad to show you some tutorials if you like.
I'm pretty sure you can find some interesting stuff in the tutorial side here in DIC

This post has been edited by Macjohn: 01 February 2012 - 06:07 AM

Was This Post Helpful? 1
  • +
  • -

#9 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

Re: jQuery dynamic change text

Posted 01 February 2012 - 06:11 AM

View PostMacjohn, on 01 February 2012 - 06:00 AM, said:

(Gonna give you some guide ligns that you can follow, you can allways keep writting here for more help..)
So, I guess you already are familiarized with PHP.
1st option - with different pages

1st - create the page(ex. page1.php) where you have your text with the 'edit' button.
2nd - create a page(ex. page_edit.php) with a textbox where your text(from the db) will fall into.
3rd - in page1 you'll need to retrieve the text from the DB -
SELECT * FROM

4th - in page_edit you'll need to retrieve the text from the DB and putting it in the textbox (the code to do that will almost be the same!
5th - add a button to the edit_page - and create the
UPDATE
function to that action.

I know I'm a bit short in words but just post if there is something that you didn't understand.
I'll be glad to show you some tutorials if you like.
I'm pretty sure you can find some interesting stuff in the tutorial side here in DIC


Thaaaaanks, for the extended answer. Thank you very much. Yea, i did fully understand you. Thats a nice way but with much (almost same) code. I'll try it out the next days.
I just asked in case there was something with much less code provided by jQuery ( like a magic function whuch turns the text to editable text :P ), but its seems there isnt :P .

Thank you very much. I do appreciate your help. I hope ill manage to make it work. If i got any problems in the future i may come into that thread again.
Was This Post Helpful? 0
  • +
  • -

#10 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: jQuery dynamic change text

Posted 01 February 2012 - 06:26 AM

Your idea is not that simple to transform that's way you'll need a more code then you think!LoOl
But thats normal
Don't worry we'll be here to help you with your code in case you need it.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1