I want to assign a value to a variable in radi button. I tried a code like this

<form method="post" action="">  <input type="submit" name="task" value="CONTINUE" onclick="$lax="5">





$task = $_POST['task'];
    switch( $task ) { 
    case 'CONTINUE':
    echo $lax;

i want the variable lax to get the value 5 while entering the switch case. I'm very new to php pls help.

First, where is your radio button ? You just posted only form and submit button. You can process PHP directly with javascript onclick event except using Ajax. You must submit the form and process at server-side then assign value in server-side or print to client-side (browser). Ensure what you want to achieve and post clearly again what you need with your codes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.