1
culex
Language define in javascript confirm ?
  • 2010/1/10 22:36

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


I am pulling my hair from this so I hope someone can save whats left of it (my hair that is)

I am trying to use language constant in a jquery / javascript confirm box, but however I try defining it, the confirm box shows eigher empty or with the raw php code inside.

Example.


// from language file

define ("_AM_INDEXSCAN_DELETESURE""Are you sure ?");

// from admin.php

php
<span class='delete'><a href='index.php?op=delete&name=$ff'><img src='delete.png'>img>a>span>

// Confirm javascript for delete file
echo "
    $(function() {
        $('.delete').click(function() {
// var text = ''
// return confirm(text);

return confirm();
        });
    });
"
;



2
xsell
Re: Language define in javascript confirm ?
  • 2010/1/10 22:56

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


do you have to echo it , can not u use html ?. see an example i use .below .beside in your Code . u wrote <Php echo _AM_INDEXSCAN_DELETESURE;
and any way why do u use the tags when u already echo your Code .
return confirm(echo _AM_INDEXSCAN_CLEAN;?>);


keep it html javescript easy to use for me this is my example for confirmation click .

<script type="text/javascript">

  
script>

3
Dylian
Re: Language define in javascript confirm ?
  • 2010/1/10 23:29

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Replace:
return confirm(echo _AM_INDEXSCAN_CLEAN;?>);

With:
return confirm("._AM_INDEXSCAN_CLEAN.");


You can just call constants like you do with variables...
(But i gues you know that but just looked over it )

Greets Dylian.

4
culex
Re: Language define in javascript confirm ?
  • 2010/1/11 0:21

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


Hey there and thanks both of you for the help.

I think I made the question a little more difficult than nessesary by posting an explanation of the problem rather than the full code, and furthermore make errors in this..

@Dylian yes I was aware, even though I am not very strong in javascript, and the echoing of the define outside the javascript works perfect, but when inside both my take on it, yours and xsells all fail.

I'm pretty sure this is something simple only I seem to be blind to see where it fails.

I'll post the original code here :)

// Language define in languages/english/admin.php

define ("_AM_INDEXSCAN_CLEAN""Are you sure you want to delete this file ?");
?>


// In indexscan/admin/admin.php

echo "".$ff.""._AM_INDEXSCAN_NOTINXOOPSINSTALL."$ff'>
";


// function to show confirm
echo "
    $(function() {
        $('.delete').click(function() {
            return confirm();
        });
    });
"
;

?>


The code is not ready to go yet I was only testing the link, message etc etc

5
Dylian
Re: Language define in javascript confirm ?
  • 2010/1/11 0:47

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Try this line:
return confirm('"._AM_INDEXSCAN_CLEAN."');

That should work, forgot the ' to pass data to the function... (FireBug comes in handy for this kind of problems )

I also noticed that the page your generating isn't xhtml compliant so here's the compliant version (if you want it ):
// In indexscan/admin/admin.php 

echo(stripslashes("
indexscan_suspecious">
    "
.$ff."
    indexscan_notxoopsinstall">
        "
._AM_INDEXSCAN_NOTINXOOPSINSTALL."
    

    delete">
        index.php?op=delete&name=".$ff."">delete.png" />
    


")); 


// function to show confirm 
echo(stripslashes("
text/javascript"> 
    $(function() { 
        $('.delete').click(function() { 
            return confirm('"
._AM_INDEXSCAN_CLEAN."'); 
        }); 
    }); 

"
)); 

?>

[edit]
The code block removes all \ 's.
[edit2]So if you wan't to use it. (but i gues you don't wan't to) You should add the \'s yourself.[/edit2]
So here it is again in a quote block. (Hopfully the \ 's won't be removed know...)
Quote:
EDIT: Didn't work either...

[/edit]

Greets Dylian.

6
culex
Re: Language define in javascript confirm ?
  • 2010/1/11 13:15

  • culex

  • Module Developer

  • Posts: 711

  • Since: 2004/9/23


Hey there again both of you

Thanks for the tips just wanted to let you know all is working now.

Xsell's version gave me an idea to test and it turned out it works if you step out of php to html

// Confirm javascript for delete file
?>

    $(document).ready(function()
    {
    $(function() {
        $('.delete').click(function() {
             
            return confirm('echo _AM_INDEXSCAN_CLEAN?>');
        });
    });
});



But thanks for helping both :)

Login

Who's Online

411 user(s) are online (286 user(s) are browsing Support Forums)


Members: 0


Guests: 411


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits