Display textbox when image onclick - image

I want to display a textbox when user click on an image.
Here is my code :
print "<img src=\"../resources/pictures/pages/edit-button.png\" height=\"18px\" onClick=\"document.getElementById('#$txtboxName').style.display=\"block\">";
print "<input type=\"text\" name=\"$txtboxName\" size=\"20\" title=\"State Permission Here\" style=\"display:none\" />";
My code wont work, any help?

see this link
$('img').on('click',function(){
$('#inputField').show();
});​

Replace with getElementByName
print "<img src=\"../resources/pictures/pages/edit-button.png\" height=\"18px\" onClick=\"document.getElementByName('#$txtboxName').style.display=\"block\">";
print "<input type=\"text\" name=\"$txtboxName\" size=\"20\" title=\"State Permission Here\" style=\"display:none\" />";

Related

MailChimp API - dynamic content - mc:repeatable + mc:edit

My email template has some intro text followed by a repeatable block [a picture + a button].
I would like to repeat this block some X times and each time have picture link and button link updated with new links.
Currently I am using this payload to edit one block, and it is working as intended. I have used this SO answer as a guideline.
var data = {
'template': {
'id': template_id,
'sections': {
'editbutton': '<a class="mcnButton " title="Get Profile" href="' + button1 + '" target="_blank" style="font-weight: bold;letter-spacing: normal;line-height: 100%;text-align: center;text-decoration: none;color: #FFFFFF;">GET DATA</a>',
'editimage': '<img alt="" src="' + image1 + '" width="564" style="max-width:564px; padding-bottom: 0; display: inline !important; vertical-align: bottom;" class="mcnImage">'
}
}
};
What I am struggling is repeating this block and updating image and button link.
I am working in Google Apps Script but I guess the problem is independence of language.
Any help would be appreciated.
Thanks.
I do not think you need to use the mc:repeatable or the mc:variant at all. Use the single mc:edit="editbutton_and_editimage_items_list" MailChimp tag. Put there dynamically generated HTML <ul><li> list with your actual data via sections part of the payload you sent to the API.
E.g. your sections.editbutton_and_editimage_items_list JSON item in your var data = {..} object above would look like:
<ul>
<li>
<a class="mcnButton " href="' + button1 + '" style="...">GET DATA</a></li>
<img alt="" src="' + image1 + '" width="564" style="..." class="mcnImage">
</li>
<!-- Repeat the LI with different data as needed --!>
</ul>
After you successfully set the template content of your yet-not-sent campaign with the data above, use the API to send the campaign.

Joomla post form

In Joomla, I am trying to post a form created directly in an article via php DirectPHP and save data to database. I don't know why but sometimes it saves the data and sometimes not. It looks like there was some cache or something because if I get the field value displayed it still shows me the first value of the form I filled out at first.
If I make any change to the code (e.g. add one row to echo whatever it works but then again the form displays this last record). Any ideas please (I don't want to use Chronoforms component).
The code in the article:
if($_GET['sent']=="ok")
{
$db = mysqli_connect("localhost", "xxxx", "xxxx", "xxxx") or die("Database not found");
mysqli_query($db, "INSERT INTO subscribe_form VALUES('','".$_GET['email_address']."')");
mysqli_close($db);
$form_sent = 1;
echo "Thank you, your email address was saved.";
}
if($form_sent==0)
{
echo "Enter your email address if you want to get subscribed.";
echo "<form action='index.php' method='get'>";
echo "</br></br>Your email address: <input type='text' name='email_address'/>";
echo "<input type='hidden' name='sent' value='ok'/>";
echo "<input type='hidden' name='option' value='com_content'>";
echo "<input type='hidden' name='Itemid' value='240'>";
echo "<input type='hidden' name='id' value='36'>";
echo "<input type='hidden' name='view' value='article'>";
echo "<input type='submit' name='odeslano' value='SAVE' />";
}
?>
The reason why your code sometimes saves the data and sometimes it doesn't is because if the email contains an escape character then it can (silently) break the query. You should cleanup $_GET['email_address'] before saving it to the database.

Get ID of a div while clicking

First sorry if my English is bad I am french x)
So I have an issue with something.
I want to get the ID of the div which I clicked on. Here's my script :
Data sent with PHP thanks to AJAX :
$id = $donnees['id'];
echo '<div class="message" id="'. $id. '">';
echo '<div class="sanction"><div class="bannir"><img src="img/ban.png" alt="ban" class="ban"></div>';
echo '<div class="supprimer"><img src="img/sup.png" alt="supprimer" class="sup"></div></div>';
echo '<div class="pseudo">' .$donnees['pseudo']. '</div>';
echo '<div class="contenu">' .$message.'</div>';
echo '</div>';
Jquery :
$('#display').on('click', '.supprimer', function(){
var id = (this).parent().attr('id');
alert(id);
});
I don't know if you understand what I want, but if someone has an idea :)
Use
$(this).prop('id');
to get the id property.

Ajax and output pdf file are not working together

I have a file named download.php and call getpdf function inside it.
I call download.php via ajax to download pdf file when users click download button. but nothing happend and no download window appears. I checked it in firebug Net tab and download.php are requested on click event. Its size also changes that shows the file is reading from its location,but no download window.
Here's getpdf code:
function getpdf($id) {
header('Content-Type: application/pdf');
readfile('/san/theo-books/PDFs/'.$id.'.pdf');
exit;
}
And here's download.php code:
$pdf_id = $_POST('pdi');
echo getpdf($pdf_id);
What is the problem? Would you help me?
Here is the full postback version. It's not using the jQuery Ajax, because Popup download window needs the full postback:
<a id="pdf-10" href="#">PDF Export</a>
$(document).ready(function () {
$('a[id^="pdf"]').click(function (event) {
event.preventDefault();
var pdfExportPath = "/san/theo-books/PDFs/";
var $a = $(this);
var postId = $a.attr('id').replace("pdf-","");
var form = $('<form action="' + pdfExportPath + '" name="pdf' + postId + '" id="pdf' + postId + '" method="POST"> <input id="id" name="id" type="hidden" value="' + postId + '" /></form>');
$(form).appendTo('body');
form.submit();
});
});

Jquery Datatable Hide delete button

I am using
$('#AffiliatedContractorLookup').dataTable().makeEditable
I want to give user the ability to add a new record , so for that purpose I used,
<div class="add_delete_toolbar" />
But this toolbar displays both Add and delete button. I want to hide the delete button. How can I acieve that ?
I know this is an old topic, but I had the same problem. I tried some solutions and here's one that worked for me:
in the file databled-editable you have this line:
if (oDeleteRowButton == null && properties.sDeleteRowButtonId != "") {
oAddDeleteToolbar.append("<button id='" + properties.sDeleteRowButtonId + "' class='delete_row'>Delete</button>");
oDeleteRowButton = $("#" + properties.sDeleteRowButtonId);
oDeleteRowButton.click(_fnOnRowDelete);
}
place it in comment, and the button won't be added
Even easier:
#btnDeleteRow
{
display:none;
}
To have only the "Add" button simply replace
<div class="add_delete_toolbar" />
with
<button id="btnAddNewRow">Add</button>

Resources