smfmetro10
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,
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="" />
Do you have a server-side scripting language available such as PHP or ASP, etc.?
Why not just do this server side?
It's more complicated using js for this at the client.
It's more complicated using js for this at the client.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah... The server side language is idoc script.... which I can't figure out :)
ASKER
Once again you have saved me!!!