hello all, i m new in php, i try to get text text box value in checkbox when i insert the data in the field if when check box is checked and then that checbox value store in database and i also need to show that if that checkbox value is in the field then the div id="abc" will change its css to strike through like

an offer price and actual price shows in ecommerce website

Recommended Answers

pleace post the code you have so far

Jump to Post

All 3 Replies

pleace post the code you have so far

here is no code i m planning to make like this one div have some value so then the div 2 css will change if div1 have some value

here is no code i m planning to make like this one div have some value so then the div 2 css will change if div1 have some value

You can use javascript to do things like that, you can either define 2 css classes or just set an inline style eg:

<style type='text/css'>
.classone{
    background-color:#eee;
    font-size:14px;
}
.classtwo{
    background-color:#faa;
    font-size:18px;
}
</style>
<div onclick="this.className='classtwo';">click me</div>
<div onclick="this.style.backgroundColor='#faa';">click me</div>

It's more common to use a select box or input for changing something like that something like this:

<script type='text/javascript'>
function changeDiv(obj,elementID){
    var targetDiv = document.getElementById(elementID);
    if(obj.value == '1'){
        targetDiv.innerHTML = 'option 1 selected';
        targetDiv.style.backgroundColor = '#fcc';
    }else if(obj.value == '2'){
        targetDiv.innerHTML = 'option 2 selected';
        targetDiv.style.backgroundColor = '#cfc';
    }else if(obj.value == '3'){
        targetDiv.innerHTML = 'option 3 selected';
        targetDiv.style.backgroundColor = '#ccf';
    }else{
        targetDiv.innerHTML = 'Please Select';
        targetDiv.style.backgroundColor = '#eee';
    }
}
</script>
<select onchange="changeDiv(this,'resultDiv');">
<option value='1'>option 1</option>
<option value='2'>option 2</option>
<option value='3'>option 3</option>
</select>
<div id='resultDiv' style='background-color:#eee;'>Please Select</div>

Personally if you are new to php i think an ecommerce website it a bit of a large project to start off on, i would start with something a bit smaller and learn it on a gradient - It's up to you though you just need to stay motivated

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.