Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Set multiple values for one field

    Hello all,
    New to the forum today. I am working on a form for a client and I am trying to get a radio button to be able to output two values and don't know how to do this.
    For example, when a customer clicks on the New PC Purchase option it outputs the value of the text "new pc purchase" into textfield1 and then it also outputs the text "649.95" into textfield2.

    This is the script that I have in place which returns the 649.95 only into a text field titled cost4output

    <script type="text/javascript" src="http://o.aolcdn.com/dojo/1.1.0/dojo/dojo.xd.js"></script>
    <script type="text/javascript">
    dojo.addOnLoad(function () {
    dojo.connect(dojo.byId("container2"), "onclick",
    function () {
    dojo.byId("cost4output").value = dojo.map(
    dojo.filter(
    dojo.query("#container2 [type='radio']"),
    "return item.checked"
    ),
    "return item.value"
    )
    multiply();
    }
    )
    })
    </script>

    And here is the html snippet which has the output fields listed. The current code is working for the cost4output field. The second field which we would like to have the "new pc purchase" entered is called hardware_4

    <input type=text name="cost4" onchange="addition()" value="" size="10" id="cost4output" class="totalField">
    <input type="text" name="hardware4" id="hardware_4" size="55" />


    And here is the html for the actual radio buttons.
    <div id="container2"><font size="+1"><strong>Low End PC</font><br /><center>
    outright
    <input type="radio" name="radiogroup2" id="radiogroup2_0" value="649.95" />
    2yr
    <input type="radio" name="radiogroup2" id="radiogroup2_1" value="549.95" />
    3yr
    <input type="radio" name="radiogroup2" id="radiogroup2_2" value="449.95" />
    </div>


    Any help would be appreciated.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Despite the similar sounding names, Java is not the same as Javascript.
    Moving from Java forum to Javascript forum.

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,984
    Thanks
    56
    Thanked 557 Times in 554 Posts
    I don't know anything about dojo, but it looks like you can do something like this:
    Code:
    <script type="text/javascript">
    dojo.addOnLoad(function () {
    dojo.connect(dojo.byId("container2"), "onclick",
    function () {
    dojo.byId("hardware_4").value = dojo.map(
    dojo.filter(
    dojo.query("#container2 [type='radio']"),
    "return item.checked"
    ),	
    "return item.value.split('|')[0]"
    )
    dojo.byId("cost4output").value = dojo.map(
    dojo.filter(
    dojo.query("#container2 [type='radio']"),
    "return item.checked"
    ),	
    "return item.value.split('|')[1]"
    )
    multiply();
    }
    )
    })
    </script>
    </head>
    <body>
    <input type=text name="cost4" onchange="addition()" value="" size="10" id="cost4output" class="totalField">
    <input type="text" name="hardware4" id="hardware_4" size="55" />
    
    
    <div id="container2"><font size="+1"><strong>Low End PC</font><br /><center>
    outright
    <input type="radio" name="radiogroup2" id="radiogroup2_0" value="new pc purchase|649.95" />
    2yr
    <input type="radio" name="radiogroup2" id="radiogroup2_1" value="reconditioned pc purchase|549.95" />
    3yr
    <input type="radio" name="radiogroup2" id="radiogroup2_2" value="crapped out pc purchase|449.95" />
    </div>
    
    </body>

  • Users who have thanked xelawho for this post:

    wcoil (09-13-2012)

  • #4
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile working great!

    Quote Originally Posted by xelawho View Post
    I don't know anything about dojo, but it looks like you can do something like this:
    Code:
    <script type="text/javascript">
    dojo.addOnLoad(function () {
    dojo.connect(dojo.byId("container2"), "onclick",
    function () {
    dojo.byId("hardware_4").value = dojo.map(
    dojo.filter(
    dojo.query("#container2 [type='radio']"),
    "return item.checked"
    ),	
    "return item.value.split('|')[0]"
    )
    dojo.byId("cost4output").value = dojo.map(
    dojo.filter(
    dojo.query("#container2 [type='radio']"),
    "return item.checked"
    ),	
    "return item.value.split('|')[1]"
    )
    multiply();
    }
    )
    })
    </script>
    </head>
    <body>
    <input type=text name="cost4" onchange="addition()" value="" size="10" id="cost4output" class="totalField">
    <input type="text" name="hardware4" id="hardware_4" size="55" />
    
    
    <div id="container2"><font size="+1"><strong>Low End PC</font><br /><center>
    outright
    <input type="radio" name="radiogroup2" id="radiogroup2_0" value="new pc purchase|649.95" />
    2yr
    <input type="radio" name="radiogroup2" id="radiogroup2_1" value="reconditioned pc purchase|549.95" />
    3yr
    <input type="radio" name="radiogroup2" id="radiogroup2_2" value="crapped out pc purchase|449.95" />
    </div>
    
    </body>
    This worked Great thanks for the quick reply!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •