Jump to content

pengi

New Members
  • Posts

    8
  • Joined

  • Last visited

pengi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello everybody, I have created a table with fixed cell width and height for each cell. Now I would like to put some text, which end with a number into the cells. I assume the height is good enough for a paragraph of 2 lines only, but the number should always be aligned right at the bottom line. I have tried this CSS: .para { display:block; margin-left:0px; margin-right:0px;} .para span { display:block; margin-left:0px; margin-right:0px; float:right; text-align:right;} With this HTML: <td height='40'><p class="para">Here is the description. <span>135</span></p></td> It works ok, but if the words and the number only spans one single line, the number will be right-aligned at Line 1 instead. On the other hand, if I change float:right to float:bottom-right, when the words spans 2 lines, the number will be dropped to the right side of Line 3. Is there any way to solve the problem so that the number is always shown on Line 2 and right-aligned? Thanks! Pengi.
  2. Hi jazzman1, Thank you for your reply and reminder (in fact, both desc and key should be avoided). However, I tried the above query and the result is Apple Apple Orange Papaya Seems to me that now when the item belongs to N categories, the names are printed N times. -- Pengi.
  3. Hello all, I have created a database with 2 tables table1 and table2 like this (except desc, all columns are integer type and the leftmost column is always the primary key): table1: pid desc ================ 1001 Apple 1002 Orange 1003 Papaya table2: key pid cat ===================== 10001 1001 101 10002 1001 102 10003 1002 101 10004 1003 102 In other words, item 1001 (Apple) belongs to categories 101 and 102, while item 1002 (Orange) belongs to cat 101 only, and item 1003 (Papaya) belongs to cat 102 only. Now I would like to make a SELECT statement that returns the name of the item(s) that belong to both categories 101 and 102 (in the above case, Apple). Any simple way (using as few statements as possible) to do this? Thanks! -- Pengi.
  4. Thank you very much. But inside the if-else, what should I do so that the original selection can be shown? I have searched the Internet and seems a solution is __doPostBack(), but the following code still does not work: <select id="z" name="sy" onChange="if (confirm('Are you sure?')) {alert('1');} else {__doPostBack('z','');}"> <option value='1' selected='selected'>Apple</option> <option value='2'>Orange</option> <option value='3'>Lemon</option> </select> Am I doing something wrong in the else part? Thanks, pengi.
  5. Hi everybody, I am just learning to use the Confirm Box feature in Javascript. I have tried to add it onto HTML form's submit buttons and checkboxes without problem. But when I add it to a HTML drop down list the behavior is a bit different and unexpected. My code looks like this: <select name='mychoice' onclick='return confirm("Are you sure?");'> <option value='1' selected='selected'>Apple</option> <option value='2'>Orange</option> <option value='3'>Lemon</option> </select> When I select one choice (whether it is Apple or Orange or Lemon), the Confirm Box pops up as expected. The problem is, when I press Cancel, the original choice will not appear, unlike checkboxes. In other words, pressing OK and Cancel will lead to the same result. Is my code wrong, or is there any simple way to make the original choice re-appear when Cancel is pressed? Thanks, pengi.
  6. Thank you both for the answers. I have done a little test on the situation with multiple submit buttons in a form, and also a text field. Yes, pressing enter once the text is entered to the text field will send the value of the first submit button. But I cannot create the scenario when the value of none of the submit buttons is sent. Anyway, since my situation does not involve other input field at all, I suppose it is safe to implement with or without hidden fields.
  7. Thank you very much. Just one more question: In such case (using multiple submit buttons without any hidden item), is the value passed from the submit button always the same as the text shown inside the button (since both rely on the content of value)? -- pengi <(")
  8. Hi everybody, I am writing an inventory system using PHP+MySQL. The system provides simple functions like Insert, Display, Update and Delete for the user to choose in Page 1. However, for Display, Update and Delete, users then have to enter the product ID in page 2, but not for the Insert function, which should directly jump to Page 3 for inserting the item specifics. As the different functions can go to different pages, in Page 1, I don't think I shall put all these function choices as radio buttons in the same form. One solution is to implement these 4 choices as 4 submit buttons, i.e. 4 forms are created. However, to differentiate among Display, Update and Delete, I need the HTML of Page 1 to carry some values to Page 2 depending on which submit button is being chosen, but apart from the choice of the 4 functions, users do not need to input anything else in Page 1. Hence I need a hidden input type, like this: <form name='1' action='Page3.php' method='post'> <!-- Insert will skip Page 2 --> <input type='Submit' value='Insert'> </form> <form name='2' action='Page2.php' method='post'> <input type='hidden' name='function' value='Display'> <input type='Submit' value='Display'> </form> <form name='3' action='Page2.php' method='post'> <input type='hidden' name='function' value='Update'> <input type='Submit' value='Update'> </form> <form name='4' action='Page2.php' method='post'> <input type='hidden' name='function' value='Delete'> <input type='Submit' value='Delete'> </form> So in Page 2, I can know which button is clicked from $_POST['function']. I believe this works, but is it a good practice? If not, is there any better solution? Thanks! -- pengi <(")
×
×
  • 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.