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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.