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

asked on

How do you assign a value to a hidden input field based on a url parameter using jquery

Hi,

I have a function that will change the value of a hidden input based on an <a> click.

What I would like to have, is first the hidden field getting a value assigned to it based on a URL parameter.  The URl will have "subjectId=" with a number assigned to it..... ( So, it could be subjectId=7.... and the hidden input (recipientId) will have a value assigned to it when the page loads.

Here is what I have so far.

Thanks,

 <script type="text/javascript">
$(document).ready(function() { 
    $("div a").click(function() {
        $("#ForMembers,#Coverage,#GenInfo").removeClass("active")
        $(this).closest("div").addClass("active")
        var v = $(this).attr("id");
        $("#recipientId").val(v);
   	if($("#recipientId").val()==6 || $("#recipientId").val()==7 || $("#recipientId").val()==8) {
	$("#contactForm").show();
		}
	else {
		$("#contactForm").hide ();
	}	
    });
});
</script

<input type="hidden" id="recipientId" name="recipientId" value=""  />

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Do you have a server-side scripting language available such as PHP or ASP, etc.?
Avatar of Gary
Why not just do this server side?
It's more complicated using js for this at the client.
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
Avatar of smfmetro10

ASKER

Yeah... The server side language is idoc script.... which I can't figure out :)
Once again you have saved me!!!