Link to home
Start Free TrialLog in
Avatar of smfmetro10
smfmetro10Flag for United States of America

asked on

how do you have a default value of a hidden input based on a url?

Hi,

I have a function that works great, but I need to add the ability of making a hidden input have a value of "6">

The name of the id of the input is" recipientId"  and here is the function.

Thanks for the help!

<script>
$(document).ready(function() { 
$('.label_copy').hide();
lhash=location.hash
if(location.hash==""){
      $("#GenInfo").addClass("active");
 }
		if(lhash==""){
			lhash="#div6"
			
		}

		$("a[href='"+lhash+"']").closest("div").addClass("active");
		$(lhash).show();
		
$('.show').click(function () {
    $('.label_copy').hide();
    $('#div' + $(this).attr('target')).show();
});

$('.hide').click(function () {
    $('.label_copy').hide();
  
});
});
</script>

Open in new window


Would it be somewhere that "lhash="#div6" is?
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In HTML:

<input type="hidden" name="yourHTMLControlName" id="recipientId" value="6" />
Avatar of smfmetro10

ASKER

Thank You!!
  Out of curiosity why doesn't $("#recipientId") = "6" work?
That's not how jquery works.
$("#recipientId") is an object, you have to specify what you want to change which in this case is the value
Ah! Thanks!