Jump to content

[SOLVED] Confirmation Box


ainoy31

Recommended Posts

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

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);
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.