Jump to content

Using AJAX with PHP forms


Mysticated

Recommended Posts

This is the procedure:

 

User logs in, PHP reads databases and populates a form

User edits form and hits save, AJAX calls PHP to write new info to database.

 

The form is echoed AND populated using Javascript. For example:

<? echo "Email: <input type=\"text\" name=\"email1\" value=\"$x\" />" ?>

 

The problem is my Javascript code can't see these functions. I can only interact with forms that were written statically. What to do?

Link to comment
Share on other sites

What is it you're trying to do? PHP and Javascript are mutually exclusive. Once the form has been written using PHP, Javascript can reference it. You just have to make sure you're referencing it accurately. Also, you need to make sure that your javascript is not trying to access form elements on the page before they are rendered in the DOM.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.