Combining Two onClick JavaScript Actions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nkoriginal
    New Member
    • Nov 2006
    • 23

    Combining Two onClick JavaScript Actions

    Hi:
    (this is a dummy question, I know, but I tried many times and I cant)
    I need to insert this javascript option inside the input, I can't insert any funtion in <head>

    I've this two javascript:

    Code:
     javascript:document.form.xrthistory.disabled=false 
    javascript:document.form.prevert.disabled=false
    and I need to put in one line inside a input type=radio, like this:

    Code:
     
    <input name="chkxrt" type="radio" value="1" onClick="javascript:document.form.xrthistory.disabled=false;document.this.prevrt.disabled=false">
    I tried with a semicolon but nothing happen.

    Could anyone help me with this??

    Thanks for any help
    nico
    Last edited by Niheel; Dec 16 '06, 08:06 PM.
  • b1randon
    Recognized Expert New Member
    • Dec 2006
    • 171

    #2
    Originally posted by nkoriginal
    Hi:
    (this is a dummy question, I know, but I tried many times and I cant)
    I need to insert this javascript option inside the input, I can't insert any funtion in <head>

    I've this two javascript:

    javascript:docu ment.form.xrthi story.disabled= false
    javascript:docu ment.form.preve rt.disabled=fal se


    and I need to put in one line inside a input type=radio, like this:

    <input name="chkxrt" type="radio" value="1" onClick="javasc ript:document.f orm.xrthistory. disabled=false; document.this.p revrt.disabled= false">

    I tried with a semicolon but nothing happen.

    Could anyone help me with this??

    Thanks for any help
    nico
    Nico, without more info I would suggest doing a separate function to execute both lines. It looks nicer too. Something like this:
    Code:
    function myFn (val){
         document.form.xrthistory.disabled=val;
         document.this.prevrt.disabled=val;
    }
    and
    Code:
    <input name="chkxrt" type="radio" value="1" onClick="javascript:myFn(false);">

    Comment

    • iam_clint
      Recognized Expert Top Contributor
      • Jul 2006
      • 1207

      #3
      or
      Code:
      <input name="chkxrt" type="radio" value="1" onClick="document.form.xrthistory.disabled=FALSE; document.this.prevrt.disabled=FALSE;">
      wirth the semicolon in the correct place

      Comment

      • nkoriginal
        New Member
        • Nov 2006
        • 23

        #4
        Thanks for your help, but I tried the two ways and nothing happend
        I paste again my code:


        <input name="chkxrt" type="radio" value="1" onClick="javasc ript:document.f orm.xrthistory. disabled=FALSE; document.this.p revrt.disabled= FALSE;">

        <input name="chkxrt" type="radio" value="0" onClick="javasc ript:document.f orm.xrthistory. disabled=TRUE; document.this.p revrt.disabled= TRUE;" checked></td>

        <select name="xrthistor y" disabled>
        <option value="select" selected="selec ted">Select</option>
        <option value="no_overl ap">No overlap</option>
        <option value="field_ma tch">Field Match</option>
        <option value="planned_ overlap">Planne d Overlap</option>
        </select>


        <textarea name="prevrt" cols="25" rows="8" wrap="VIRTUAL" id="prevrt" onKeyUp=chkLeng th(this,"248") disabled ><%=prevrt%></textarea>


        With this code when any user press YES, the onclick activate the dropdown menu and the textarea at same time.

        If I use only this function in my radio input:
        javascript:docu ment.form.xrthi story.disabled= FALSE

        my dropdown menu works ok but my textarea NOT!

        Do you have any idea how I can fix this problem??

        Thank you
        nico

        Comment

        • jonavanmona
          New Member
          • Nov 2006
          • 11

          #5
          maybe because you didnt enabled it..

          javascript:docu ment.form.xrthi story.disabled= FALSE;
          document.form.p revrt.disabled= FALSE ;

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Originally posted by nkoriginal
            With this code when any user press YES, the onclick activate the dropdown menu and the textarea at same time.

            If I use only this function in my radio input:
            javascript:docu ment.form.xrthi story.disabled= FALSE

            my dropdown menu works ok but my textarea NOT!

            Do you have any idea how I can fix this problem??
            I don't understand. Isn't that what it's supposed to do?! If you only enable your dropdown menu and not your textarea, that is exactly what will happen. The code that you pasted above this quote in your post with both xrthistory and prvrt (the textarea) enabled is correct. What exactly are you trying to achieve? Please explain in more detail.

            Comment

            • nkoriginal
              New Member
              • Nov 2006
              • 23

              #7
              Originally posted by acoder
              I don't understand. Isn't that what it's supposed to do?! If you only enable your dropdown menu and not your textarea, that is exactly what will happen. The code that you pasted above this quote in your post with both xrthistory and prvrt (the textarea) enabled is correct. What exactly are you trying to achieve? Please explain in more detail.
              Hi,

              Thanks to everybody to help me.

              when somebody select YES (radio button) my textarea and my dropdown menu come active, if they select NO, my textarea and dropdown is inactive.

              so, I need one radio button to active or desactive a: dropdown menu and textarea.

              in this case, two onlick in one radio button.

              thank you to everybody
              nico

              Comment

              • iam_clint
                Recognized Expert Top Contributor
                • Jul 2006
                • 1207

                #8
                Heres an example i made up for you.
                Code:
                <input type="radio" name="r1" onclick="document.getElementById('ta').disabled = false; document.getElementById('se').disabled = false;">Yes <input type="radio" name="r1" onclick="document.getElementById('ta').disabled = true; document.getElementById('se').disabled = true;">No<br>
                <textarea id="ta" disabled="true">Test</textarea><br>
                <select id="se" disabled="true">
                <option>1</option>
                <option>2</option>
                <option>3</option>
                </select>

                Comment

                • nkoriginal
                  New Member
                  • Nov 2006
                  • 23

                  #9
                  Originally posted by iam_clint
                  Heres an example i made up for you.
                  Code:
                  <input type="radio" name="r1" onclick="document.getElementById('ta').disabled = false; document.getElementById('se').disabled = false;">Yes <input type="radio" name="r1" onclick="document.getElementById('ta').disabled = true; document.getElementById('se').disabled = true;">No<br>
                  <textarea id="ta" disabled="true">Test</textarea><br>
                  <select id="se" disabled="true">
                  <option>1</option>
                  <option>2</option>
                  <option>3</option>
                  </select>
                  thank you so much for your help!
                  The code is working perfect!

                  :D:D:

                  nico

                  Comment

                  Working...