Prototype or JQuery change the value of a hidden field?

Posted by Nick Faraday on Stack Overflow See other posts from Stack Overflow or by Nick Faraday
Published on 2010-02-03T02:24:15Z Indexed on 2010/04/06 20:23 UTC
Read the original article Hit count: 350

Filed under:
|

I'm having some trouble with prototype changing the value of a hidden field.

Function:

function remove_fields (link) {
    $(link).next('input[type=hidden]').value = '';
    $(link).up(".open_hours").hide();
}

If I comment out the $(link).next('input[type=hidden]').value = ''; the hide function works. Trying to set the value gives me an error:

$(link).next("input[type=hidden]") is undefined

Here is my HTML around the function call:

    <div class="monday">

        <div class ="open_hours">
            <li><label for="location_monday">Monday</label>
            Open: 06:29PM - 
            Close: 04:21PM 
            <a href="#" onclick="remove_fields(this); return false;">remove</a></li>

            <li class="hidden optional" id="location_monday_open_input"><input id="location_monday_open" name="location[monday_open]" type="hidden" value="18:29:00" /></li>
            <li class="hidden optional" id="location_monday_close_input"><input class="close" id="location_monday_close" name="location[monday_close]" type="hidden" value="16:21:00" /></li>
  </div>    
</div>

Not sure what I'm doing wrong here? Thanks Guys!

© Stack Overflow or respective owner

Related posts about prototype

Related posts about jQuery