How do I embed Javascript in PHP code? -


i have html form , php code. in form, have textbox , textarea. within both, have included "disabled" option. want both textboxes remain disabled until user decides click "edit" button, in case both textboxes should enabled changes can made , output once again saved. according research have done, way use javascript, have included following code within php;

if (isset($_post['edit'])) {     echo "<script type=\"text/javascript\">";     echo "var oldnotes = document.getelementbyid('oldnotes');";     echo "oldnotes.disabled = false;";     echo "var record = document.getelementbyid('record');";     echo "record.disabled = false;";     echo "</script>"; } 

i have tried;

if (isset($_post['edit'])) {     echo "<script type=\"text/javascript\">";     echo "$('#oldnotes').removeattr('disabled')";     echo "$('#record').removeattr('disabled')";     echo "</script>"; } 

but no luck :(

i not receiving errors, textboxes remain disabled after click edit button. me this? in advance.

try use onclick on button

<input type="button" name="edit" id="edit" onclick="document.getelementbyid('oldnotes').disabled=false; document.getelementbyid('record').disabled=false; return false;"> 

i hope helps.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -