HZGN.COM
welcome to my space
X
Welcome to:hzgn.com
Search:  
NAVIGATION: Home >>

How to pass value from html to javascript ?

Published by: cfz 2009-01-08

  • Hi,

    I have two questions.

    #First

    How to pass value from html to javascript? Currently I'm doing like this :

    My javascript :

    Ext.onReady(function() {
    var image = Ext.get('show-win');

    image.on('click', function(r) {
    Ext.Msg.alert('Status', r.target.alt);

    });

    My html :



    But I don't like this method because I'm passing value through 'alt' tag.Is there any way other than this method?

    #Second

    From my above codes, I would like to trigger image.on('click', function(r) {.... from a href (text link).Any idea?

    Thank!


  • Hi,

    Thanks for your help.But unfotunately I don't get what do you mean.Is it like this ? :

    PHP :

    getResult() as $value) {?>

    getid() ?>" style="cursor: pointer;" />




    Javascript :

    Ext.onReady(function(r) {

    Ext.select('img.popup').on('click', function(r) {
    Ext.Msg.alert('Status', r.target.id);

    });

    Really need your help.Thanks again!


  • 1) If you're binding the event handler to the image, at that point don't you already know what the alt text is going to be? If you don't, how you're doing it isn't necessarily that bad, the other option would be setting up some kind of mapping, like:


    var values = {};
    values['show-win'] = 'This is the value';

    Ext.onReady(function() {
    Ext.fly('show-win').on('click', function(e) { Ext.Msg.alert('Status', values[e.getTarget().id]); });

    });


    2) Not quite sure what you mean here?


  • I got now! It's now work! This is my final solution :

    My PHP

    getResult() as $value) {?>

    getid() ?>" style="cursor: pointer;" />



    My Javascript

    Ext.onReady(function() {

    Ext.select('img.test').on('click', function(r) {
    Ext.Msg.alert('Status', r.target.id);

    });

    Thanks Evant!


  • For the first issue, you could assign each image a classname, then use:


    Ext.select('img.popup').on('click', ....);


    For the second, the same thing applies, just select the element and apply an onclick handler.


  • Hi,

    Thanks for your fast reply!

    What I want try to do is,I want to launch MsgAlert for each link through loop that I created using php :

    getResult() as $value) {?>

    getid() ?>" style="cursor: pointer;" />



    ..and this is the javascript


    Ext.onReady(function(r) {

    var image = Ext.get(What id?);

    image.on('click', function(r) {
    Ext.Msg.alert('Status', r.target.id);

    });

    My problem is what 'id' to pass to Ext.get(What id?); because my id is unique and generated at runtime by php.

    #Second

    For second issue,instead of clicking image,I want to show MsgAlert when clicking text (example normal link)

    Thanks!





  • Red Hat's Rough Recovery From CFO Exit
    Windows Live Finds a New, Pre-installed Home

    #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about How to pass value from html to javascript ? , Please add it free.
  • how to host international students
  • foreign exchange program
  • i have a low gpa but high sat scores where do you think i 039 ll be able to get into
  • what universities for architecture
  • what is the latest studies in the world
  • wthis summer i might go to europe how can i make friends while abroad hat would you like to ask
  • could anyone help 10 pnts for best answer wasl help
  • ap bio 10 points easy question
  • can someone help me choose between these to universities
  • what are some unique and or helpful sat tips
  • i am going abroad for my post graduation and i have a question
  • is there a limit to how many times one can study abroad
  • student summer exchange
  •  
  • question on my iq test results
  • is top 99 the same as 99th percentile
  • should i got to australia to study
  • my family and i would like to host a forign exstange student
  • i want to be an exchange student this summer to travel to a foreign country possibly the u k what program
  • should i go study in autralia
  • wich is better to take gre or toefl
  • loans and scholarships for us student attending school in uk
  • i got a one on my ap biology exam and im taking the sat biology exam on the 6th of december
  • studying abroad at oxford london area
  • returning to uk want to re take my gcse
  • do i need to go to a two years college to become
  • what a levels do you need for accountancy
  • is it really worth the money to go and take a four or six week intensive language course in a foreign county
  • About us |Contact us |Advertisement |Site map |Exchange links
    Copyright© 2008hzgn.com All Rights Reserved