Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Lecture 7 Answers


Published on

  • Be the first to comment

  • Be the first to like this

Lecture 7 Answers

  1. 1. IS4 030 - Website Design for e-Commerce By SMIEEE, SMACM, MACS E-mail: Room: P7919 Consultation Hours: 3:30 - 5:30pm Monday Lecture Seven –JavaScript and XML
  2. 2. While Loop <p>Explanation:</p> <p><b>i</b> equal to 0.</p> <p>While <b>i</b> is less than , or equal to, 5, the loop will continue to run.</p> <p><b>i</b> will increase by 1 each time the loop runs.</p> </body> </html> Question: How many number will be displayed on the Web page?
  3. 3. Array <ul><li>An array is simply a collection of similar variables storing similar data items e.g., a collection of customer names: </li></ul>Edison Guil CustName[0] CustName[1] The CustName array Computer Main Memory (RAM) Sa Question: What is the advantage of using array instead of using ordinary variables?
  4. 4. HTML DOM - Form <ul><li><html> </li></ul><ul><li><body> </li></ul><ul><li><form name=“Raymond”> </li></ul><ul><li>The form's name is: <input type=&quot;text&quot; name=&quot;text1&quot; size=&quot;20&quot;> </li></ul><ul><li><br /><br /> </li></ul><ul><li><input type=&quot;button&quot; value=&quot;Show the form's name&quot; onClick=&quot;;> </li></ul><ul><li></form> </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul><ul><li>Question: </li></ul><ul><li>How is the output on the Web page after the “Show form’s name” button is clicked? </li></ul>
  5. 5. indexof Method <ul><li><html> </li></ul><ul><li><body> </li></ul><ul><li><body> </li></ul><ul><li><script type=&quot;text/javascript&quot;> </li></ul><ul><li>var str=“CitySchools is great!&quot; </li></ul><ul><li>var pos=str.indexOf(&quot;School&quot;) </li></ul><ul><li>if (pos>=0) </li></ul><ul><li>{ </li></ul><ul><li>document.write(&quot;School found at position: &quot;) </li></ul><ul><li>document.write(pos + &quot;<br />&quot;) </li></ul><ul><li>} </li></ul><ul><li>else </li></ul><ul><li>{ </li></ul><ul><li>document.write(&quot;School not found!&quot;) </li></ul><ul><li>} </li></ul><ul><li></script> </li></ul><ul><li><p>This example tests if a string contains a specified word. If the word is found it returns the position of the first character of the word in the original string. Note: The first position in the string is 0!</p> </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul>