9 Replies - 1216 Views - Last Post: 07 May 2013 - 06:36 AM

#1 smart11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 23-March 13

change background and font color by writing color name on the box

Posted 10 April 2013 - 04:31 AM

Hellow everybody,

please anyone can help me I am trying to creat aweb page hase three boxes.

the first box to change or enter title color: e.g (yellow)
the second box to enter background color: (green)
the third box to enter font color: (red)

then only one button to apply all these boxes.


I begin with this


<html>
<body><title>forms</title>
<form>

enter title color:<input type="text" name="title" ;document.bgColor="yellow"><br>
enter backgroud color:<input type="text"  name="background" ;document.bgColor="green"><br>
enter font color:<input type="text"  name="font" ;document.fgColor="red"><br>
<input type="button" value="apply" onclick="change_Color();">

</form>
</body>
</html>



Is This A Good Question/Topic? 0
  • +

Replies To: change background and font color by writing color name on the box

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,319
  • Joined: 08-June 10

Re: change background and font color by writing color name on the box

Posted 10 April 2013 - 04:43 AM

Id use classes for that, way easier to handle than the CSS properties itself.
Was This Post Helpful? 1
  • +
  • -

#3 smart11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 23-March 13

Re: change background and font color by writing color name on the box

Posted 10 April 2013 - 05:03 AM

ok but waht can I do with the button ?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,319
  • Joined: 08-June 10

Re: change background and font color by writing color name on the box

Posted 10 April 2013 - 07:00 AM

you can use the button (well, you could also omit the button alltogether) to trigger the function that does the changes (like in your code).
Was This Post Helpful? 1
  • +
  • -

#5 smart11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 23-March 13

Re: change background and font color by writing color name on the box

Posted 10 April 2013 - 08:01 AM

Tip: click inside this box to load tلإhe editor
Was This Post Helpful? 0
  • +
  • -

#6 smart11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 23-March 13

Re: change background and font color by writing color name on the box

Posted 10 April 2013 - 08:14 AM

thanks in advance ....but I am still confused
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,319
  • Joined: 08-June 10

Re: change background and font color by writing color name on the box

Posted 10 April 2013 - 10:25 PM

confused about what?
Was This Post Helpful? 0
  • +
  • -

#8 smart11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 23-March 13

Re: change background and font color by writing color name on the box

Posted 11 April 2013 - 05:32 AM

sorry I read it later,

you said that I can create this web page with CSS but I couldnot do that because I have to write each color in a different box to change the color of background ,font and the title when I press the button so I have to write the colors in these boxes in html page how can we connect the function of the button with variables (the names of the color)

I hope you could understand my question.
Was This Post Helpful? 0
  • +
  • -

#9 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,319
  • Joined: 08-June 10

Re: change background and font color by writing color name on the box

Posted 11 April 2013 - 05:57 AM

ah, ok, that doesn’t make sense with classes.

nevertheless, you need the handler function to read (and verify) the values and then apply the CSS settings (e.g. via the style property) on the document body (resp. the title).

This post has been edited by Dormilich: 11 April 2013 - 05:58 AM

Was This Post Helpful? 0
  • +
  • -

#10 smart11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 23-March 13

Re: change background and font color by writing color name on the box

Posted 07 May 2013 - 06:36 AM

This is the right answer

<html>
<head>
<title>colors</title>
<script type="text/javascript">
function apply_settings()
{
document.title=document.form1.pagetitle.value;
document.bgColor=document.form1.bgcolor.value;
document.fgColor=document.form1.fontcolor.value;
}

</script>
</head>
<body>
<form name="form1">

enter title:<input type="text" name="pagetitle"><BR>

enter background color:<input type="text" name="bgcolor"><BR>

enter font color:<input type="text" name="fontcolor"><BR>

<input type="Button" Value="apply" onclick="apply_settings();"/>

</form>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1