ainoy31 Posted September 2, 2008 Share Posted September 2, 2008 Hello- I have two drop down menu and when the user clicks save, I have a confirmation box that pops up to confirm their selection. Here is my code for the menu: Product: <select name="secondary_rating_product" class="smaller" id="product"> <? for($x = 0; $x < $numCount; $x++) { ?> <option value="<?=$data[$x]->productItemId ?>"><?=$data[$x]->name?></option> </select> Priority Level: <select name="priority_level" class="smaller" id="level"> <? for($x = 1; $x <= $y; $x++) { ?> <option value="<?=$x?>"><?=$x?></option> <?}?> </select> Here is the javascript for the confirmation box. function confirmSelect() { var prod = document.getElementById('product').value; var lvl = document.getElementById('level').value; return confirm("Please confirm your selection.\n" + "Secondary Rating Product: " + prod + "\n" + "Priority Level: " + lvl); } Everything is working fine except one thing. In the confirmation box with the Secondary Rating Product, it displays the numerical ID of the product but I need it to display the name of it. I know that if I change the <option value="<?=$data->productItemId?>"><?=$data->name?></option> to <option value="<?=$data->name?>"><?=$data->name?></option> it will work. However, I need the product ID since I am using that to insert into the DB. Is this possible to do with what I have currently? Hope this is clear enough. Thanks. AM Link to comment https://forums.phpfreaks.com/topic/122433-solved-confirmation-box/ Share on other sites More sharing options...
Psycho Posted September 2, 2008 Share Posted September 2, 2008 function confirmSelect() { var prodSelObj = document.getElementById('product'); var lvlSelObj = document.getElementById('level'); var prodText = prodSelObj.options[prodSelObj.selectedIndex].text; var lvlText = lvlSelObj.options[lvlSelObj.selectedIndex].text; var confirmMsg = "Please confirm your selection.\n" + "Secondary Rating Product: " + prodText + "\n" + "Priority Level: " + lvlText return confirm(confirmMsg); } Link to comment https://forums.phpfreaks.com/topic/122433-solved-confirmation-box/#findComment-632208 Share on other sites More sharing options...
ainoy31 Posted September 2, 2008 Author Share Posted September 2, 2008 Thanks man. Working as I needed it to. Link to comment https://forums.phpfreaks.com/topic/122433-solved-confirmation-box/#findComment-632232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.