0

can someone help me out getting a javascript var inside the value of a form input value?

I'm a newbie in javascript but can give you my solution in php. ("Just use php" isn't an option because it have to be client-based :D )

<?php
$value = "Hello!";
?>

<form name="settings" action="">
   <input name="color" value="<?php echo $value; ?>" />
</form>

Thanks in advance

2 Answers 2

2

Like this:

document.forms["settings"].color.value = "your value goes here...";
Sign up to request clarification or add additional context in comments.

Comments

0
<?php
$value = "Hello!";
?>

<form name="settings" action="">
   <input name="color" value="" />
</form>  
<script>
document.forms["settings"].color.value = "<?php echo $value;?>";
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.