Liste déroulante et champ

Nathalie -  
 Vince -
Bonjour à tous, j'ai besoin d'aide s.v.p.

voici mon prob. J'ai une liste déroulante et je voudrais que quand on clic sur un choix de cette liste, un champ text s'affiche, selon le choix effectué.
Une exemple. Dans ma liste il y a les choix kilometrage, hebergement, location. Je voudrais qu'en cliquant sur un de ces choix, un nouveau champ s'affiche avec le montant correspondant au choix.

J'espère que j'ai été assez clair dans mes explications.

Merci beaucoup à l'avance pour votre aide!

15 réponses

  1. ephp
     
    salut,
    j'ai trouvé une solution mais pas avec une liste déroulante mais avec des bouton radio
    0
  2. SirHill Messages postés 4070 Statut Contributeur 543
     
    Salut Nathalie,
    euhh tu pourrais repréciser un peu ta question, je n'ai pas très bien compris: en cliquant sur un choix de ta liste, tu souhaiterais voir s'afficher: un nouveau champ texte (textfield/textarea?), du texte tout court (s'affichant dans une zone de ta page) ou une nouvelle liste déroulante?
    @+
    0
  3. Laurent G Messages postés 35 Statut Membre 4
     
    dans le cas où c'est pour un site web, il te faut faire çà avec du java script.
    Donne moi plus de précision pour que je cherche le code
    0
  4. Utilisateur anonyme
     
    Solution plutot simple, en javascript :
    tu crées tous tes champs de texte et tu les rends invisible;
    tu mets un attribut 'onchange=fonction()' à ta liste déroulante ou fonction() est le nom d'une fonction javascript qui va s'occuper de voir quel champ rendre visible.
    Facile... à dire!

    Fat_Cartman,
    Parce que je le vaux bien... 
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. Nathalie
     
    Allo!
    Ce que je veux faire est assez simple (je crois!) mais je n'y arrive pas!J'ai une liste déroulante qui contient des choix de dépenses comme hébergement, location auto, autres et etc...J'aimerais qu'en cliquant sur un choix de la liste, un champ contenant le montant correspondant à la dépense s'affiche. J'essai avec SelectedIndex (pour savoir quel choix a été fait dans la liste) mais ca ne fonctionne pas!

    Merci de votre aide!!
    0
  7. Laurent G Messages postés 35 Statut Membre 4
     
    une solution à tester :
    lorsque tu crée ta liste déroulante, tu mets dans le champs
    option : onclick=Prix( );

    Dans ta fonction javascript Prix, tu cherche la valeur sémlectionnée par l'utilisateur (document.nomDeTonFormulaire.SelectedIndex )
    et en fonction de sa tu affiche le montant.
    0
  8. Utilisateur anonyme
     
    LaurentG a tres bien reformulé ce que j'ai dit, c'est vrai que je n'etais pas clair... Mais à la place de onClick, c'est simplement onChange.
    Ca y est, c'est fait??

    Fat_Cartman,
    Parce que je le vaux bien... 
    0
  9. Laurent G Messages postés 35 Statut Membre 4
     
    autant pour moi Fat_Cartman, je n'est pas lu ton message, donc je n'avais pas vu ue tu l'avais déjà dit.

    Sorry !!
    0
  10. Utilisateur anonyme
     
    Y'a pas de mal, tu es plus explicite que moi donc c'est ok!

    Fat_Cartman,
    Parce que je le vaux bien... 
    0
  11. ephp
     
    salut nathalie,
    j'ai trouvé une solution la voici:
    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    var choix1 = new Array("kilometrage", "hebergement", "location")
    var choix2 = new Array(300, 250, 350)
    function getData(form) {
    var i = form.choix3.selectedIndex
    form.choix4.value = choix2[i]
    }
    </SCRIPT>
    </HEAD>

    <BODY onLoad="getData(document.officeData)">
    <FORM NAME="officeData">
    <P>
    <SELECT NAME="choix3" onChange="getData(this.form)">
    <OPTION >kilometrage
    <OPTION >hebergement
    <OPTION >location
    </SELECT>
    </P><P>
    <INPUT TYPE="text" NAME="choix4">
    </P>
    </FORM>
    </BODY>
    </HTML>

    tiens moi au courant @+
    0
    1. Nathalie
       
      Je te remercie énormément, c'est exactement ce que je voulais que ca fasse!

      Merci encore.
      0
  12. Utilisateur anonyme
     
    sivouplé on ferme les balises <option></option> et les <input />!!
    A part ca, ca a l'air bien....

    Fat_Cartman,
    Parce que je le vaux bien... 
    0
    1. ephp
       
      salut,
      meci pour les conseils,tu a raison sur les balises <option></option> mais pas pour les inputs en plus on peut les ecrire sans fermeture
      0
      1. Utilisateur anonyme > ephp
         
        Oui, tu peux laisser les <input> ouverts... tout en produisant du html non conforme aux normes du W3C. Mais ca apres, c'est ton choix, tu fais du travail propre et conforme, ou tu fais bucheron...

        Fat_Cartman,
        Parce que je le vaux bien... 
        0
  13. appolinaire
     
    Bonjour ,
    Voici un programme que je ne parviens pas à obtenir des
    resultats interessant. car il me convertir les big-endian en little-endian.
    merci pour votre aide.

    Version d'origine à l'adresse
    //aeolus.nascom.nasa.gov/pub/merged

    PROGRAM READ_RT_FILE
    C*******************************************************************
    C* READ_RT_FILE Read whole file for real-time TRMM and Other Data *
    C* *
    C* This program provides an example of reading the whole file for *
    C* each of the three data files produced by the real-time TRMM and *
    C* Other Data precipitation estimation system. It is set up to *
    C* prompt the user for a file name and data type, then the header *
    C* and values of all fields are output for the four boxes *
    C* surrounding the intersection of the Date Line and Equator. *
    C* NOTES: *
    C* 1. The units for specifying FORTRAN unformatted direct access *
    C* record size are system-dependent. On SGI it's in 4-byte *
    C* words, but other machines use the number of bytes. *
    C* 2. The data are written big-endian, so little-endian machines *
    C* might require byte swapping, unless gzip has successfully *
    C* handled it. *
    C** *
    c !!! this is the conversion of big-endian to little-endian *
    c !!! dd if=inputfilename of=outputfilename conv=swab *
    C* Log: *
    C* G.Huffman/SSAI 12/01 *
    C*******************************************************************
    IMPLICIT NONE
    INTEGER*4 LN, LT90, LT60
    PARAMETER ( LN = 1440,
    + LT90 = 720,
    + LT60 = 480 )
    C
    C The arrays are dimensioned for fully global fields to accomodate
    C 3B40RT. 3B41RT and 3B42RT only cover the latitude band 60N-S,
    C which is accounted for by reading only 480 rows.
    C Arrays: p - estimated precipitation (mm/hr)
    C e - estimated precipitation random error (mm/hr)
    C npixels - number of original data pixels contributing to
    C gridbox estimates
    C nambig - number of original data pixels that are
    C classified as "ambiguous"
    C nrain - number of original data pixels that are
    C classified as raining
    C nsource - source of estimate (<0, 0, 100 = none, HQ, IR)
    C
    REAL*4 p (LN, LT90), e (LN, LT90)
    INTEGER*1 npixel (LN, LT90), nambig (LN, LT90),
    + nrain (LN, LT90), nsource (LN, LT90),
    + i1dum (LN, LT90)
    INTEGER*4 iret, i, j, i1, j1
    CHARACTER*256 type, name
    CHARACTER*2880 head
    C
    C Prompt for file name.
    C
    WRITE (*, *) 'Enter file name:'
    READ (*, 10) name
    10 FORMAT ( A256 )
    C
    C Prompt for data type.
    C
    WRITE (*, *) 'Enter data type (3B40RT, 3B41RT, 3B42RT):'
    READ (*, 10) type
    C
    C Case 1: 3B40RT - merged microwave, or high quality (HQ)
    C Call the example reading routine and write out the values of
    C all five fields for the four boxes surrounding the intersection
    C of the Date Line and the Equator.
    C
    IF ( type (1:6) .EQ. '3B40RT' ) THEN
    CALL GET_ARRS_FILE ( name, 5, LN, LT90, head, p, e,
    + npixel, nambig, nrain, iret )
    IF ( iret .LT. 0 ) STOP
    C
    C Case 2: 3B41RT - variable rainrate infrared (VAR).
    C
    ELSE IF ( type (1:6) .EQ. '3B41RT' ) THEN
    CALL GET_ARRS_FILE ( name, 3, LN, LT60, head, p, e,
    + npixel, i1dum, i1dum, iret )
    IF ( iret .LT. 0 ) STOP
    C
    C Case 3: 3B42RT - VAR merged with HQ (VARHQ).
    C
    ELSE IF ( type (1:6) .EQ. '3B42RT' ) THEN
    CALL GET_ARRS_FILE ( name, 3, LN, LT60, head, p, e,
    + nsource, i1dum, i1dum, iret )
    IF ( iret .LT. 0 ) STOP
    C
    C Case 4: Any other input is not recognized.
    C
    ELSE
    WRITE (*, *) 'Error - don''t recognize data type ',
    + type (1:6)
    STOP
    END IF
    C
    C Write out the header and values at the points around the
    C intersection of the Date Line and Equator.
    C
    WRITE (*, *) 'Header:'
    WRITE (*, *) head

    open(23, file = 'resu.txt')
    C
    IF ( type (1:6) .EQ. '3B40RT' ) THEN
    WRITE (*, *) 'i, j, p, e, npixel, nambig, nrain:'
    i1 = LN / 2
    j1 = LT90 / 2
    DO j = j1, j1+1
    DO i = i1, i1+1
    WRITE (*, 100) i, j, p (i, j), e (i, j), npixel (i, j),
    + nambig (i, j), nrain (i, j)
    100 FORMAT ( 2I5, 2F10.2, 3I4 )
    END DO
    END DO
    ELSE IF ( type (1:6) .EQ. '3B41RT' ) THEN
    WRITE (*, *) 'i, j, p, e, npixel:'
    i1 = LN / 2
    j1 = LT60 / 2
    DO j = j1, j1+1
    DO i = i1, i1+1
    WRITE (23, 110) i, j, p (i, j), e (i, j), npixel (i, j)
    110 FORMAT ( 2I5, 2F10.2, I4 )
    END DO
    END DO
    ELSE
    WRITE (*, *) 'i, j, p, e, nsource:'
    i1 = LN / 2
    j1 = LT60 / 2
    DO j = j1, j1+1
    DO i = i1, i1+1
    WRITE (*, 110) i, j, p (i, j), e (i, j), nsource (i, j)
    END DO
    END DO
    END IF
    C
    STOP
    END
    C
    SUBROUTINE GET_ARRS_FILE ( name, n, LN, LT, head, p, e, np1,
    + np2, np3, iret )
    C********************************************************************
    C* GET_VAR_FILE Do whole-file read of a real-time file *
    C* *
    C* This subroutine opens the specified TRMM and Other Data *
    C* precipitation estimate file and reads all the specified arrays *
    C* in a single record, converting the first two from scaled I*2 to *
    C* R*4. *
    C* *
    C* GET_ARRS_FILE ( name, n, LN, LT, head, p, e, np1, np2, np3, *
    C* iret ) *
    C* *
    C* Input parameters: *
    C* name CHAR* File name *
    C* n INT Number of fields (1,2,3,4,5) *
    C* LN INT X size *
    C* LT INT Y size *
    C* *
    C* Output parameters: *
    C* head CHAR* File header *
    C* p REAL* Precip field in mm/hr (size LN,LT) *
    C* e REAL* Precip error field in mm/hr (size LN,LT) *
    C* np1 BYTE* Precip companion field 1 (number or source) *
    C* (size LN,LT) *
    C* np2 BYTE* Precip companion field 2 (number or source) *
    C* (size LN,LT) *
    C* np3 BYTE* Precip companion field 3 (number or source) *
    C* (size LN,LT) *
    C* iret INT Return code: 0 = normal *
    C* -1 = local array too small *
    C* -2 = I/O error *
    C* -3 = header array too short *
    C** *
    C* Log: *
    C* G.Huffman/SSAI 12/01 Adapt GET_ARRS.F *
    C********************************************************************
    IMPLICIT NONE
    REAL*4 RMISS
    INTEGER*4 LNL, LTL
    INTEGER*2 I2MISS
    PARAMETER ( LNL = 1440,
    + LTL = 720,
    + RMISS = -99999.,
    + I2MISS = -31999 )
    C
    INTEGER*4 LN, LT, n, iret
    REAL*4 p (LN, LT), e (LN, LT)
    BYTE np1 (LN, LT), np2 (LN, LT), np3 (LN, LT)
    CHARACTER*(*) name, head
    C
    INTEGER*4 iunit, l_n, i, j, l_head, lrec, iostat, joff
    INTEGER*2 i2p (LNL, LTL), i2e (LNL, LTL)
    CHARACTER*1 dum
    LOGICAL in_use
    C
    C Check that the local array is big enough.
    C
    IF ( LNL .LT. LN .OR. LTL .LT. LT ) THEN
    WRITE (*, *) 'Error: local work array too small, with',
    + LNL, ',', LTL, ' .LT.', LN, ',', LT
    iret = -1
    RETURN
    END IF
    C
    C Open the file. Start by finding a free FORTRAN unit number.
    C The logical record is the entire set of fields requested.
    C The header and precip field are required in this example, but
    C the following fields are optional. lrec is sized as follows:
    C header (1 line of I*2): LN / 2 words
    C precip (field of I*2): LT * LN / 2 words
    C error (field of I*2): LT * LN / 2 words
    C companion field 1 (field of I*1): LT * LN / 4 words
    C companion field 2 (field of I*1): LT * LN / 4 words
    C companion field 3 (field of I*1): LT * LN / 4 words
    C
    C ==> The units for specifying FORTRAN unformatted direct <==
    C ==> access record size are system-dependent. On SGI it's <==
    C ==> in 4-byte words, but other machines use the number of <==
    C ==> bytes <==
    C
    in_use = .TRUE.
    iunit = 2
    DO WHILE ( in_use )
    iunit = iunit + 1
    INQUIRE ( iunit, OPENED=in_use )
    END DO
    C
    lrec = LN * 2 + LT * LN * 2
    IF ( n .GT. 1 ) lrec = lrec + LT * LN / 2
    IF ( n .GT. 2 ) lrec = lrec + LT * LN / 4
    IF ( n .GT. 3 ) lrec = lrec + LT * LN * 3
    IF ( n .GT. 4 ) lrec = lrec + LT * LN / 4

    lrec = lrec*4

    OPEN ( UNIT = iunit, ACCESS = 'DIRECT',
    + FILE = name, FORM = 'UNFORMATTED',
    + RECL = lrec, IOSTAT = iostat,
    + ERR = 15 )
    GO TO 16
    15 WRITE (*, *) 'Error', iostat, ' opening ', name
    iret = -2
    RETURN
    16 CONTINUE
    C
    C Do the read. It's an error if the receiving header array is
    C short. Note that the header byte length is explicitly
    C stated to ensure that the data are correctly aligned.
    C
    l_head = LEN ( head )
    IF ( l_head .LT. LN * 2 ) THEN
    WRITE (*, *) 'Error: header size (', l_head,
    + ' bytes) .LT. one row (', LN*2, ' bytes)'
    iret = -3
    RETURN
    END IF
    C
    IF ( n .EQ. 1 ) THEN
    READ ( iunit, REC=1, ERR=100, IOSTAT=iostat ) head (1:2880),
    + ( ( i2p (i, j), i = 1, LN ), j = 1, LT )
    ELSE IF ( n .EQ. 2 ) THEN
    READ ( iunit, REC=1, ERR=100, IOSTAT=iostat ) head (1:2880),
    + ( ( i2p (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( i2e (i, j), i = 1, LN ), j = 1, LT )
    ELSE IF ( n .EQ. 3 ) THEN
    READ ( iunit, REC=1, ERR=100, IOSTAT=iostat ) head (1:2880),
    + ( ( i2p (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( i2e (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( np1 (i, j), i = 1, LN ), j = 1, LT )
    ELSE IF ( n .EQ. 4 ) THEN
    READ ( iunit, REC=1, ERR=100, IOSTAT=iostat ) head (1:2880),
    + ( ( i2p (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( i2e (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( np1 (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( np2 (i, j), i = 1, LN ), j = 1, LT )
    ELSE
    READ ( iunit, REC=1, ERR=100, IOSTAT=iostat ) head (1:2880),
    + ( ( i2p (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( i2e (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( np1 (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( np2 (i, j), i = 1, LN ), j = 1, LT ),
    + ( ( np3 (i, j), i = 1, LN ), j = 1, LT )
    END IF
    C
    C Convert the precip from scaled (by 100) I*2.
    C
    DO j = 1, LT
    DO i = 1, LN
    IF ( i2p ( i, j ) .EQ. I2MISS ) THEN
    p (i, j) = RMISS
    ELSE
    p (i, j) = i2p ( i, j ) * .01
    END IF
    END DO
    END DO
    C
    C Convert the error from scaled (by 100) I*2, if requested.
    C
    IF ( n .GT. 1 ) THEN
    DO j = 1, LT
    DO i = 1, LN
    IF ( i2e ( i, j ) .EQ. I2MISS ) THEN
    e (i, j) = RMISS
    ELSE
    e (i, j) = i2e ( i, j ) * .01
    END IF
    END DO
    END DO
    END IF
    C
    CLOSE ( iunit )
    iret = 0
    RETURN
    C
    C I/O error return.
    C
    100 WRITE (*, *) 'Read error', iostat, ' on', name
    CLOSE ( iunit )
    iret = -2
    RETURN
    END
    0
  14. SirHill Messages postés 4070 Statut Contributeur 543
     
    Salut Appolinaire,
    Le mieux serait de reposter ton message dans le forum...
    il est noyé ici!
    @+
    0
  15. Laurent G Messages postés 35 Statut Membre 4
     
    je suis tout à fait d'accord avec fat_cartman !
    autant faire du travail propre, sa coute pas plus cher !
    0
  16. Vince
     
    Ajouté par fat_cartman(14/04/2004 à 16:28 GMT+1)
    sivouplé on ferme les balises <option></option> et les <input />!!
    A part ca, ca a l'air bien....

    Ajouté par fat_cartman(15/04/2004 à 08:56 GMT+1)
    Oui, tu peux laisser les <input> ouverts... tout en produisant du html non conforme aux normes du W3C. Mais ca apres, c'est ton choix, tu fais du travail propre et conforme, ou tu fais bucheron...

    eh! Fat_Cartman.....
    Tu sais ta culture, c'est comme la confiture....!
    (tu connais la suite....)
    Si c'est pour ne rien dire, alors abstient toi !!!!!
    Au lieu de faire ton "prof" de bas étage...!
    0