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

    Question input text box javascript function call without ID name possible or anyway overload?

    Right now spectrum gets called for the input box showInputAndInitial through docs.js function that is labled $("#showInputAndInitial").spectrum()

    my question is can I use just the one function in docs.js or do I need to make a new function entry for every single input box, My page will have somewhere around 25 input boxes, so I was hoping there was a more efficient method than just making a ton of entries in docs.js (anyway to not use the id name to call the function?):


    example of php page:
    <link rel="stylesheet" type="text/css" href="css/default.css">
    <link rel="stylesheet" type="text/css" href="css/spectrum.css">
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript" src="js/spectrum.js"></script>
    <script type='text/javascript' src='js/docs.js'></script>
    <input type='text' name='showInputAndInitial' id='showInputAndInitial' value='daa520' />
    <input type='text' name='showInputAndInitial2' id='showInputAndInitial2' value='daa520' />
    <input type='text' name='showInputAndInitial3' id='showInputAndInitial3' value='daa520' />
    <input type='text' name='showInputAndInitial4' id='showInputAndInitial4' value='daa520' />
    <input type='text' name='showInputAndInitial5' id='showInputAndInitial5' value='daa520' />
    $(function() {
    		preferredFormat: "hex",
    		showPalette: true,
    		showSelectionPalette: true,
    		palette: [ ],
    		localStorageKey: "jitest.homepage", // Any Spectrum with same string will share
    		showInitial: true,
    		showInput: true
    Last edited by xekon; 02-06-2013 at 01:20 AM.

  2. #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Thanked 626 Times in 605 Posts
    $("input[type=text][name][value][id]") will hit only text inputs with name, ID, and value attribs: most likely the droids you are looking for. use a wrapping container with an ID if you need to be more specific.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  3. Users who have thanked rnd me for this post:

    xekon (02-06-2013)


Tags for this Thread

Posting Permissions

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