PDA

View Full Version : javascript question



deus3X
27 Oct 2007, 8:46 AM
i try to pass some php variable to a an Ext.onReady function but can't do it. here's the function:


Ext.onReady(function(){

Ext.get('del').on('click', function(e){
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', del);
});

function del(btn){
if (btn == 'yes'){
function JumpToURL(surl) { window.location.href = surl; }
}

else {
window.location.href='';
}

};


here's the call:


<form><select name="jumpMenu" id="del" OnChange="JumpToURL(this.value);">
<option value="">Actions</option>
<option value="delete.php?email='.$row['email'].'&id='.$row['id'].'">Delete</option>
</select></form>

i fell that i'm mixing something between the del function and my JumpToUrl function but i don't get it.

Thanks for your help.

hendricd
27 Oct 2007, 11:00 AM
:>

deus3X
27 Oct 2007, 11:18 AM
thank you but i don't get it. the del function is conditional to the Ext.get so if i put the Ext.get after it doesn't work. it would work if there would be no condition but it's a validation box so the no should return nothing. i think it's a very dummy mistake but i still don't see it !

jay@moduscreate.com
27 Oct 2007, 1:21 PM
Why are you going though that trouble? Why not just write an array and dynamically create a dropdown based on the json or array data?

deus3X
28 Oct 2007, 3:55 AM
you are certainly right. the reason i'm doing that is because i transfer my old php code and didn't want to change everything. but since i'm still stuck i will dig your json idea. thank you.

jay@moduscreate.com
28 Oct 2007, 4:29 AM
Think of it as a great learning exercise :)

rballman
29 Oct 2007, 9:23 AM
Instead of creating the "del" function, how can you get the value of the "btn" variable? For example:



Ext.get('del').on('click', function(e){
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', function(){alert(btn);});
});

rodiniz
29 Oct 2007, 9:35 AM
Ext.get('del').on('click', function(e){
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', function(btn){alert(btn);});
});
Its the first argument passed to the function it doesn't matter if the function has or not a name..

rballman
29 Oct 2007, 9:37 AM
Thanks for the quick response. Works perfectly!