facebook

how to show alert with value of textField1: CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #327819 Reply

    luckay
    Member

    Dear All,

    I am new to MobiOne, I am trying to show an alert with the value of textField1.. but it does not work
    could any body please help?

    I set the Actions property of push1 to PopupAlert and then
    $(‘#textField1’).text()

    I also had tried to use run javascript below.. but still no luck 🙁

    function alertText(){
    var myTextField = document.getElementById(‘textField1’);
    if(myTextField.value != “”)
    alert(“You entered: ” + myTextField.value)
    else
    alert(“Would you please enter some text?”)
    }

    any help would be appreciated..

    thanks a lot in advance

    Regards
    Win

    Attachments:
    You must be logged in to view attached files.
    #327823 Reply

    Kale
    Member

    Hi,

    try this code:

    function displayAlertWindow(){
      var myValue = $('#m1-YourAppName-textField1').val();
    
      if(myValue!=""){
        alert('Your text is:' + myValue);
      }else{
        alert('Please enter text!');
      }
      }​

    Greetings Kale

    #327825 Reply

    luckay
    Member

    Thanks, I tried it .. but it does not show anything 🙁
    any idea?

    #327826 Reply

    Kale
    Member

    Works perfectly on my side. I have created a textfield and a button and saved the project as ‘YourAppName’. The button calls the function displayAlertWindow()

    Make sure that the function is called correctly and change the name of the textfield in the code.

    $(‘#m1-YourAppName-textField1′)

    Greetings Kale

    #327827 Reply

    luckay
    Member

    yes, I am sure..

    my application name is test1.mobi .. so it would be $(‘#m1-test1-textField1’)

    any comment? or did I miss something?

    #327828 Reply

    luckay
    Member

    yes, I am sure..

    my application name is test1.mobi as enclosed . so it would be $(‘#m1-test1-textField1’) ..

    any comment? or did I miss something?

    Attachments:
    You must be logged in to view attached files.
    #327835 Reply

    Kale
    Member

    Hmm, don´t know why, but I can´t post code here anymore. Getting an error that I don´t have permission.

    “Forbidden

    You don’t have permission to access /support-genuitec/posting.php on this server.”

    #327836 Reply

    Kale
    Member

    Use the attached file and insert the function code in test1_custom.js at the end.

    I removed the code from the Run Java Script Code Window and left only the function call.

    You have to insert the whole code (beginning with function) from your original Run Java Script Window in test1_custom.js.

    If I could post code it would be easier for me to show you.

    Greetings Kale

    Attachments:
    You must be logged in to view attached files.
    #327858 Reply

    luckay
    Member

    Hi..
    I copied the function into test1_custom.js at the end as enclosed and set the onclick event to displayAlertWindow()

    but it does not triggered … any idea? ..
    please help

    Thanks & Regards

    Attachments:
    You must be logged in to view attached files.
    #327860 Reply

    Kale
    Member

    I attached a zip file with a working version. Just extract it and open the project, it works fine on my side. Please let me know the differences between your version and the version I attached, because I really don´t know what could cause the problem on your side.

    Greetings Kale

    Attachments:
    You must be logged in to view attached files.
    #327863 Reply

    luckay
    Member

    Hi,

    Yours is working properly.. I am still checking what the different between yours and mine (not working) .. strange .. I also enclosed it for your review ..

    Attachments:
    You must be logged in to view attached files.
    #327873 Reply

    Kale
    Member

    At the very end of your code there is a “?”.

    Delete it and everything works properly. 😉

    Greetings Kale

    #327876 Reply

    luckay
    Member

    Hi Kale,

    Thanks for your help 🙂 .. I am very new with this, so this is very helpful for me and as a kick-off playing with MobiOne..
    Again.. Thanks a lot .. and have a nice day 🙂

    Regards
    Winanjaya

Viewing 13 posts - 1 through 13 (of 13 total)
Reply To: how to show alert with value of textField1: CLOSED

You must be logged in to post in the forum log in