9 Replies - 640 Views - Last Post: 19 January 2013 - 07:21 PM Rate Topic: -----

#1 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

new to php

Posted 19 January 2013 - 04:56 AM

hi im new to php and i searched this code that adds elements to m program and i can't seem to access the code when i open it on my browser on localhost/(myfile) here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
<title>Dynamically add Textbox, Radio, Button in html Form using Javascript</title>
<script language="javascript">
function add(type) {
 
    //Create an input type dynamically.
    var element = document.createElement("input");
 
    //Assign different attributes to the element.
    element.setAttribute("type", type);
    element.setAttribute("value", type);
    element.setAttribute("name", type);
 
 
    var foo = document.getElementById("fooBar");
 
    //Append the element in page (in span).
    foo.appendChild(element);
 
}
</SCRIPT>
</head>
<body>
<FORM>
<H2>Dynamically add element in form.</H2>
Select the element and hit Add to add it in form.
<BR/>
<SELECT name="element">
    <OPTION value="button">Button</OPTION>
    <OPTION value="text">Textbox</OPTION>
    <OPTION value="radio">Radio</OPTION>
</SELECT>
 
<INPUT type="button" value="Add" onclick="add(document.forms[0].element.value)"/>
 
<span id="fooBar">&nbsp;</span>
 
</FORM>
</body>



Is This A Good Question/Topic? 0
  • +

Replies To: new to php

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2988
  • Posts: 10,323
  • Joined: 08-August 08

Re: new to php

Posted 19 January 2013 - 05:32 AM

Don't be a copy/paste programmer and you won't have these types of problems!
  • There is no PHP code in what you've shown.
  • You can't access PHP code from a browser because PHP is processed on the server.

Was This Post Helpful? 0
  • +
  • -

#3 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: new to php

Posted 19 January 2013 - 06:58 AM

View PostCTphpnwb, on 19 January 2013 - 05:32 AM, said:

Don't be a copy/paste programmer and you won't have these types of problems!
  • There is no PHP code in what you've shown.
  • You can't access PHP code from a browser because PHP is processed on the server.

i already figure it out sir thanks ^^
but i have another question is it possible to save the elements as it is added the way i want it to look?
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2988
  • Posts: 10,323
  • Joined: 08-August 08

Re: new to php

Posted 19 January 2013 - 07:23 AM

Yes.
Was This Post Helpful? 0
  • +
  • -

#5 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: new to php

Posted 19 January 2013 - 12:35 PM

View PostCTphpnwb, on 19 January 2013 - 07:23 AM, said:

Yes.

can you show some links that might help sir? if it is ok with you
Was This Post Helpful? 0
  • +
  • -

#6 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

Re: new to php

Posted 19 January 2013 - 02:37 PM

http://www.phptherightway.com/
Was This Post Helpful? 0
  • +
  • -

#7 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: new to php

Posted 19 January 2013 - 05:58 PM

View Postcreativecoding, on 19 January 2013 - 02:37 PM, said:


sir what do I need to this? would I be learning array to do it sir?
Was This Post Helpful? 0
  • +
  • -

#8 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

Re: new to php

Posted 19 January 2013 - 06:19 PM

You are not going to learn how to program and make things by copy and pasting code. It's common sense. Will you learn the contents of a test if you copy off another person? No.

Learn PHP and naturally you will learn how to solve problems you have. If for whatever reason you don't want to do that, you can hire someone to do it for you.
Was This Post Helpful? 0
  • +
  • -

#9 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: new to php

Posted 19 January 2013 - 06:47 PM

View Postcreativecoding, on 19 January 2013 - 06:19 PM, said:

You are not going to learn how to program and make things by copy and pasting code. It's common sense. Will you learn the contents of a test if you copy off another person? No.

Learn PHP and naturally you will learn how to solve problems you have. If for whatever reason you don't want to do that, you can hire someone to do it for you.

ok sir thanks for the advise but one last question am I learning the right programming language because i read the code and its javascript i think but its working
Was This Post Helpful? 0
  • +
  • -

#10 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

Re: new to php

Posted 19 January 2013 - 07:21 PM

yes the code you posted is javascript.

Javascript is ran on the "clients" side. Meaning it is ran on your user's computer when they go to your website. It can do things like manipulate forms (like you did above).

PHP is ran on the "server" side. Meaning it is ran on your computer hosting the website. It can do things like store information.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1