getElementById containing/similar to

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cptuser
    New Member
    • Mar 2007
    • 30

    getElementById containing/similar to

    Hi,

    I'm new to javascript. I need to be able to set a variable what get the value by an ID that contains a particular let and not exactly. Can one use a wild card?
    Here is what I'm trying to do:

    [CODE=javascript]var start_t_mon = document.getEle mentById("*_par tofid").value,[/CODE]

    So I want to set this variable for any form field value that contains "_partofid" !
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, CPT.

    You'll like these better:
    [CODE=javas cript]
    JavaScript code goes here.
    [/CODE]

    Comment

    • cptuser
      New Member
      • Mar 2007
      • 30

      #3
      Originally posted by pbmods
      Heya, CPT.

      You'll like these better:
      [CODE=javascript]
      JavaScript code goes here.
      [/CODE]
      Thanks for the tip. Are you able to assist with my query?

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, CPT.

        document.getEle mentById() does not support globbing, but you might find it useful to use the name property combined with document.getEle mentsByName():

        [code=html]
        <div id="1_partofid " name="partofid" >...</div>
        <div id="2_partofid " name="partofid" >...</div>
        [/code]
        [code=javascript]
        var divs = document.getEle mentsByName('pa rtofid');
        [/code]

        Comment

        Working...