0

I need urgent help. I need ONLY select ALL button for my code:

if($_POST['SmartPhone']==false and $_POST['Apple']==false)
{
$this->add(new error('<span style="color:red">Select your cell..!!</span>'));
$this->step1();
return;
}
if(isset($_POST['S4']))
$tech2=$_POST['S4'];
$form->add_checkbox('S4','S4',$tech2);
if(isset($_POST['iPhone 5']))
$tech3=$_POST['iPhone 5'];
$form->add_checkbox('iPhone_5','iPhone 5',$tech3);
if(isset($_POST['iPhone 5s']))
$tech1=$_POST['iPhone 5s'];
$form->add_checkbox('iPhone_5s','iPhone 5s',$tech1);
//In addition, i want to know how to put "Select All" button here
// in order to SELECT ALL MODELs: S4, iPhone 5, iPhone_5s

I am beginner at JavaScript.

Thanks in adv for your time.

3
Contributors
5
Replies
26
Views
3 Years
Discussion Span
Last Post by PriteshP23
0

Hi,

This code looks like php. What are you trying to do once you have selected all models?

If you use JQuery it sounds like you want something like:

 $('.selectAll').on('click' , function(){

$('.checkbox').prop('checked', true);
});

You would just need to make the class of each checkbox class="checkbox".

0

It would help to see the HTML that is generated to be able to provide guidance on the javascript/jQuery.

Aside from adding these elements using PHP, you need to target the elements as suggested by piers. You can target elements in a variety of ways using selectors, such as by element type, class, id, etc..

0

It would help to see the HTML that is generated to be able to provide guidance on the javascript/jQuery.

Actually i need to do operation on database based on selected model and than generate XML file.

This code looks like php. What are you trying to do once you have selected all models?

Yes, it is PHP code. here

But it seems, for SELECT ALL, i have to use JavaScript. So, i post here.

Thanks in advanced to give an example (if possible) of what you have said.

Edited by PriteshP23: code

0

It sounds like you need to look into RESTful web services.

In PHP for writing the xml file you can use
This is assuming in your html you give the name of all your checkboxes
nocheckbox.

With jquery you could do:

     $('.selectAll').on('click' , function(){
    // add in name change
    $('.nocheckbox').prop('checked', true).attr('name','checkbox');



    });

Then in your PHP something like this:

$checkbox = $_POST['checkbox'];

while($row = mysql_fetch_array($checkbox)) {

$yourData = "<elem>".$row[$checkbox]."</elem>";

$file = fopen("file.xml","w");
fwrite($file,$yourData);
fclose($file);
}
0

I am sorry but i didn't get you.

I do not know how to apply your logic to get expected output.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.