More Elegant Buttons to submit data to script
I am hoping someone can help
I have the following script part
function buttonOneClick(){
sendData= "map_icon=car";
initialize();
}
function buttonTwoClick(){
sendData= "map_icon=boat";
initialize();
}
function buttonThreeClick(){
sendData= "map_icon=motorcycle";
initialize();
}
function buttonfourClick(){
sendData= "map_icon=services";
initialize();
}
The above functions could easily go to about 50 buttons like these
<button type="btn btn-mini btn-primary"
onclick="buttonOneClick()">Cars</button>
<button type="btn btn-mini btn-primary"
onclick="buttonTwoClick()">Boats</button>
<button type="btn btn-mini btn-primary"
onclick="buttonThreeClick()">Motorcycles</button>
<button type="btn btn-mini btn-primary"
onclick="buttonfourClick()">Services</button>
again for each function I have a button
is there a more elegant way to create the function that handles the buttons?
example: How do I create one function to handle all the buttons?
The sendData is a variable which I could easily add to the button from the
database
I am using JavaScript, jquery, Ajax, PHP and a MYSQL db and can create a
loop for the buttons.
No comments:
Post a Comment