onkeypress

Discussion in 'Javascript' started by jr.civetta, Oct 26, 2005.

  1. jr.civetta

    jr.civetta Guest

    hi

    i ve made this

    function form(diam, pas){
    var form = document.createElement('form');
    form.setAttribute('name', diam);
    form.setAttribute('id', diam);
    var oPas = document.createElement('input');
    oPas.setAttribute('type', 'hidden');
    oPas.setAttribute('name', 'pas');
    oPas.setAttribute('value', pas);
    var oAngle= document.createElement('input');
    oAngle.setAttribute('type','text');
    oAngle.setAttribute('name', 'angle');
    oAngle.setAttribute('value', '2');
    oAngle.setAttribute('size', '2');
    oAngle.onkeypress = 'return deplacement(this.form)';
    var oDep = document.createElement('input');
    oDep.setAttribute('name', 'dep');
    oDep.setActive('size', '4') ;
    oDep.setActive('type', 'text');
    form.appendChild( document.createTextNode('M' + diam + ': '));
    form.appendChild(oPas);
    form.appendChild(document.createTextNode('angle'));
    form.appendChild(oAngle);
    form.appendChild(document.createTextNode('deplacement :'));
    form.appendChild(oDep);
    document.body.appendChild(form);
    }

    when i call the function when the page load

    the statement "oAngle.onkeypress" doesn t work
    where I have make an error?
    i don t need browser compatibilty (it will be use into an IE browser
    embedded into pro-engineer wildfire(cad software))
    tia
     
    jr.civetta, Oct 26, 2005
    #1
    1. Advertisements

  2. jr.civetta

    aundro Guest

    assuming 'deplacement' names a function that you previously defined,
    you want:
    oAngle.onkeypress = deplacement
    (document.getElementById('myForm'));
    instead of:
    oAngle.onkeypress = 'return deplacement(this.form)';

    of course, then you first need to name your form:
    [...]
    form.id = 'myForm';
    document.body.appendChild (form);

    Hope that helps,
    Arnaud



    --
    Arnaud DIEDEREN
    Software Developer
    IONIC Software
    Rue de Wallonie, 18 - 4460 Grace-Hollogne - Belgium
    Tel: +32.4.3640364 - Fax: +32.4.2534737
    mailto:
    http://www.ionicsoft.com
     
    aundro, Oct 26, 2005
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.