Ok, so this seems like it should be very straight forward, but I have been stuck on this for hours. Objective: I want to store a variable on my page based on if I last clicked on the "Delivery" or "Pickup" div section of the page.
I have Jquery that uses the following code to switch what is shown on the page (first segment in section). Everything works except .value and .innerHTML:
$(document).ready(function(){
$("#pickup_click_link").click(function(){
$('#delivery_stuff').fadeOut('fast', function(){
$('#pickup_stuff').fadeIn('fast');
});
$('#delivery_stuff2').fadeOut('fast', function(){
$('#pickup_stuff2').fadeIn('fast');
});
$("#pickup_button").css("background-color","silver");
$("#delivery_button").css("background-color","white");
window.onload = function(){
document.getElementById('pu_del_nav_var').value='Pickup';
document.getElementById('pu_del_nav_varTEST').innerHTML='Pickup';
}
});
});
$(document).ready(function(){
$("#delivery_click_link").click(function(){
$('#pickup_stuff').fadeOut('fast', function(){
$('#delivery_stuff').fadeIn('fast');
});
$('#pickup_stuff2').fadeOut('fast', function(){
$('#delivery_stuff2').fadeIn('fast');
});
$("#pickup_button").css("background-color","white");
$("#delivery_button").css("background-color","silver");
delivery_click();
});
});
I tried to put the code that is giving me the error (.value ="Pickup/Delivery" and .innerHTML="Pickup/Delivery") onload, in a seperate function, after the Div and Input, but I always get the error Uncaught TypeEror: Cannot set property 'value' of null
function delivery_click() {
document.getElementById('#pu_del_nav_var').value='Delivery';
document.getElementById('#pu_del_nav_varTEST').innerHTML='Delivery';
alert("Delivery!");
}
How can I get this javascript to work so it changes this input and the information where "temp here" is?
<input type="hidden" id="pu_del_nav_var" name="pu_del_nav_var" value="Pickup">
<div name='pu_del_nav_varTEST' id='pu_del_nav_varTEST'>temp here</div>